@@ -829,6 +829,51 @@ func (r *accountRepository) ListSchedulableByPlatforms(ctx context.Context, plat
829829 return r .accountsToService (ctx , accounts )
830830}
831831
832+ func (r * accountRepository ) ListSchedulableUngroupedByPlatform (ctx context.Context , platform string ) ([]service.Account , error ) {
833+ now := time .Now ()
834+ accounts , err := r .client .Account .Query ().
835+ Where (
836+ dbaccount .PlatformEQ (platform ),
837+ dbaccount .StatusEQ (service .StatusActive ),
838+ dbaccount .SchedulableEQ (true ),
839+ dbaccount .Not (dbaccount .HasAccountGroups ()),
840+ tempUnschedulablePredicate (),
841+ notExpiredPredicate (now ),
842+ dbaccount .Or (dbaccount .OverloadUntilIsNil (), dbaccount .OverloadUntilLTE (now )),
843+ dbaccount .Or (dbaccount .RateLimitResetAtIsNil (), dbaccount .RateLimitResetAtLTE (now )),
844+ ).
845+ Order (dbent .Asc (dbaccount .FieldPriority )).
846+ All (ctx )
847+ if err != nil {
848+ return nil , err
849+ }
850+ return r .accountsToService (ctx , accounts )
851+ }
852+
853+ func (r * accountRepository ) ListSchedulableUngroupedByPlatforms (ctx context.Context , platforms []string ) ([]service.Account , error ) {
854+ if len (platforms ) == 0 {
855+ return nil , nil
856+ }
857+ now := time .Now ()
858+ accounts , err := r .client .Account .Query ().
859+ Where (
860+ dbaccount .PlatformIn (platforms ... ),
861+ dbaccount .StatusEQ (service .StatusActive ),
862+ dbaccount .SchedulableEQ (true ),
863+ dbaccount .Not (dbaccount .HasAccountGroups ()),
864+ tempUnschedulablePredicate (),
865+ notExpiredPredicate (now ),
866+ dbaccount .Or (dbaccount .OverloadUntilIsNil (), dbaccount .OverloadUntilLTE (now )),
867+ dbaccount .Or (dbaccount .RateLimitResetAtIsNil (), dbaccount .RateLimitResetAtLTE (now )),
868+ ).
869+ Order (dbent .Asc (dbaccount .FieldPriority )).
870+ All (ctx )
871+ if err != nil {
872+ return nil , err
873+ }
874+ return r .accountsToService (ctx , accounts )
875+ }
876+
832877func (r * accountRepository ) ListSchedulableByGroupIDAndPlatforms (ctx context.Context , groupID int64 , platforms []string ) ([]service.Account , error ) {
833878 if len (platforms ) == 0 {
834879 return nil , nil
0 commit comments