@@ -466,10 +466,11 @@ const filterUsers = async (req, res) => {
466
466
467
467
// one time script function to perform the migration - adding github_user_id field to the document
468
468
const migrate = async ( req , res ) => {
469
+ // pat yet to be generated
469
470
const authToken = `${ config . get ( "githubOauth.patToken" ) } ` ;
470
471
// converting the `authToken` string into Base64 format
471
472
const encodedToken = Buffer . from ( `${ authToken } ` ) . toString ( "base64" ) ;
472
- const usernameNotFound = [ ] ;
473
+ const usersNotFound = [ ] ;
473
474
let countUserNotFound = 0 ;
474
475
try {
475
476
// Fetch user data from GitHub API for each document in the users collection
@@ -500,11 +501,11 @@ const migrate = async (req, res) => {
500
501
. catch ( ( error ) => {
501
502
if ( error . response && error . response . status === 404 ) {
502
503
countUserNotFound ++ ;
503
- const userNotFound = {
504
+ const invalidUsers = {
504
505
name : `${ userName } ` ,
505
506
username : `${ githubUsername } ` ,
506
507
} ;
507
- usernameNotFound . push ( userNotFound ) ;
508
+ usersNotFound . push ( invalidUsers ) ;
508
509
} else {
509
510
// Other error occurred
510
511
logger . error ( "An error occurred at axios.get:" , error ) ;
@@ -519,7 +520,7 @@ const migrate = async (req, res) => {
519
520
return res . status ( 200 ) . json ( {
520
521
message : "All Users github_user_id added successfully" ,
521
522
data : {
522
- invalidUsers : usernameNotFound ,
523
+ invalidUsers : usersNotFound ,
523
524
totalCount : countUserNotFound ,
524
525
} ,
525
526
} ) ;
0 commit comments