@@ -347,19 +347,21 @@ pub async fn get_unpopulated_clone_of_games(
347347pub fn get_unmatched_games_without_clone_of_with_limit < ' a > (
348348 provider : MetadataProviderEnum ,
349349 page_size : u64 ,
350+ cursor : Option < Uuid > ,
350351 conn : DbConn ,
351352) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
352- get_unmatched_games_with_limit ( provider, true , true , page_size, conn)
353+ get_unmatched_games_with_limit ( provider, true , true , page_size, cursor , conn)
353354}
354355
355356/// Return up to `page_size` games without a successful mapping for `provider` that are
356357/// clones of another game. Returns `Ok(None)` when there is nothing left to process.
357358pub fn get_unmatched_games_with_clone_of_with_limit < ' a > (
358359 provider : MetadataProviderEnum ,
359360 page_size : u64 ,
361+ cursor : Option < Uuid > ,
360362 conn : DbConn ,
361363) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
362- get_unmatched_games_with_limit ( provider, false , true , page_size, conn)
364+ get_unmatched_games_with_limit ( provider, false , true , page_size, cursor , conn)
363365}
364366
365367/// Same as [`get_unmatched_games_without_clone_of_with_limit`] but does not require the
@@ -369,19 +371,21 @@ pub fn get_unmatched_games_with_clone_of_with_limit<'a>(
369371pub fn get_unmatched_games_without_clone_of_with_limit_no_platform_gate < ' a > (
370372 provider : MetadataProviderEnum ,
371373 page_size : u64 ,
374+ cursor : Option < Uuid > ,
372375 conn : DbConn ,
373376) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
374- get_unmatched_games_with_limit ( provider, true , false , page_size, conn)
377+ get_unmatched_games_with_limit ( provider, true , false , page_size, cursor , conn)
375378}
376379
377380/// Same as [`get_unmatched_games_with_clone_of_with_limit`] but without the platform
378381/// mapping gate. See [`get_unmatched_games_without_clone_of_with_limit_no_platform_gate`].
379382pub fn get_unmatched_games_with_clone_of_with_limit_no_platform_gate < ' a > (
380383 provider : MetadataProviderEnum ,
381384 page_size : u64 ,
385+ cursor : Option < Uuid > ,
382386 conn : DbConn ,
383387) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
384- get_unmatched_games_with_limit ( provider, false , false , page_size, conn)
388+ get_unmatched_games_with_limit ( provider, false , false , page_size, cursor , conn)
385389}
386390
387391/// Min interval between cross-pass attempts on the same failed mapping.
@@ -401,13 +405,14 @@ pub const CROSS_MATCH_RETRY_INTERVAL_DAYS: i64 = 7;
401405pub fn get_failed_games_for_cross_pass_with_limit < ' a > (
402406 provider : MetadataProviderEnum ,
403407 page_size : u64 ,
408+ cursor : Option < Uuid > ,
404409 conn : DbConn ,
405410) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
406411 Box :: pin ( async move {
407412 let cooldown = Utc :: now ( ) - Duration :: days ( CROSS_MATCH_RETRY_INTERVAL_DAYS ) ;
408413 let cooldown_naive: NaiveDateTime = cooldown. naive_utc ( ) ;
409414
410- let res = Game :: find ( )
415+ let mut query = Game :: find ( )
411416 . join (
412417 JoinType :: InnerJoin ,
413418 game:: Relation :: SignatureMetadataMapping . def ( ) ,
@@ -450,7 +455,13 @@ pub fn get_failed_games_for_cross_pass_with_limit<'a>(
450455 )
451456 . to_owned ( ) ,
452457 ) ) ,
453- )
458+ ) ;
459+
460+ if let Some ( after) = cursor {
461+ query = query. filter ( game:: Column :: Id . gt ( after) ) ;
462+ }
463+
464+ let res = query
454465 . order_by_asc ( game:: Column :: Id )
455466 . limit ( page_size)
456467 . all ( & conn)
@@ -470,13 +481,14 @@ pub fn get_failed_games_for_cross_pass_with_limit<'a>(
470481pub fn get_automatic_match_failed_games_with_limit < ' a > (
471482 provider : MetadataProviderEnum ,
472483 page_size : u64 ,
484+ cursor : Option < Uuid > ,
473485 conn : DbConn ,
474486) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
475487 Box :: pin ( async move {
476488 let sixty_days_ago = Utc :: now ( ) - Duration :: days ( 60 ) ;
477489 let sixty_days_ago_naive: NaiveDateTime = sixty_days_ago. naive_utc ( ) ;
478490
479- let res = Game :: find ( )
491+ let mut query = Game :: find ( )
480492 . join (
481493 JoinType :: LeftJoin ,
482494 game:: Relation :: SignatureMetadataMapping . def ( ) ,
@@ -490,7 +502,13 @@ pub fn get_automatic_match_failed_games_with_limit<'a>(
490502 )
491503 . and ( signature_metadata_mapping:: Column :: UpdatedAt . lt ( sixty_days_ago_naive) )
492504 . and ( signature_metadata_mapping:: Column :: Provider . eq ( provider) ) ,
493- )
505+ ) ;
506+
507+ if let Some ( after) = cursor {
508+ query = query. filter ( game:: Column :: Id . gt ( after) ) ;
509+ }
510+
511+ let res = query
494512 . order_by_asc ( game:: Column :: Id )
495513 . limit ( page_size)
496514 . all ( & conn)
@@ -509,6 +527,7 @@ fn get_unmatched_games_with_limit<'a>(
509527 clone_of_null : bool ,
510528 require_platform_mapping : bool ,
511529 page_size : u64 ,
530+ cursor : Option < Uuid > ,
512531 conn : DbConn ,
513532) -> BoxFuture < ' a , anyhow:: Result < Option < Vec < game:: Model > > > > {
514533 Box :: pin ( async move {
@@ -543,7 +562,7 @@ fn get_unmatched_games_with_limit<'a>(
543562 ) ;
544563 }
545564
546- let res = query
565+ query = query
547566 . filter ( if clone_of_null {
548567 game:: Column :: CloneOf . is_null ( )
549568 } else {
@@ -569,7 +588,13 @@ fn get_unmatched_games_with_limit<'a>(
569588 . to_owned ( ) ,
570589 )
571590 . not ( ) ,
572- )
591+ ) ;
592+
593+ if let Some ( after) = cursor {
594+ query = query. filter ( game:: Column :: Id . gt ( after) ) ;
595+ }
596+
597+ let res = query
573598 . order_by_asc ( game:: Column :: Id )
574599 . limit ( page_size)
575600 . all ( & conn)
0 commit comments