@@ -443,6 +443,7 @@ component {
443443 token = token
444444 );
445445 successCount ++ ;
446+ sleep (500 );
446447 } catch (any e ) {
447448 application .fc .lib .error .logData (application .fc .lib .error .normalizeError (e ));
448449 }
@@ -805,7 +806,6 @@ component {
805806 }
806807
807808 public query function getReverseMigratableUsers (string userIDs , numeric maxRows = -1 ) {
808- maxRows = min (maxRows , 5000 );
809809 var qAllUsers = queryNew (" profileID, userID, email, given_name, family_name, name, user_id, password_hash, email_verified" );
810810
811811 var userCondition ;
@@ -964,6 +964,30 @@ component {
964964 }
965965
966966 public void function reverseMigration (required query qUsers ) {
967+ var safeBatchSize = 5000 ;
968+ if (qUsers .recordCount <= 5000 ) {
969+ try {
970+ processReverseBatch (arguments .qUsers );
971+ } catch (any e ) {
972+ application .fc .lib .error .logData (application .fc .lib .error .normalizeError (e ));
973+ }
974+ } else {
975+ var totalRows = qUsers .recordCount ;
976+ var currentIndex = 1 ;
977+
978+ while (currentIndex <= totalRows ) {
979+ try {
980+ var endIndex = min (currentIndex + safeBatchSize - 1 , totalRows );
981+ var batchQuery = createBatchQuery (qUsers , currentIndex , endIndex );
982+ processReverseBatch (arguments .qUsers );
983+ } catch (any e ) {
984+ application .fc .lib .error .logData (application .fc .lib .error .normalizeError (e ));
985+ }
986+ currentIndex + = safeBatchSize ;
987+ }
988+ }
989+ }
990+ public void function processReverseBatch (required query qUsers ) {
967991 // remove new user records
968992 removeUserRecords (qUsers = arguments .qUsers );
969993
0 commit comments