Skip to main content

claim_due

Function claim_due 

Source
pub async fn claim_due(
    conn: &mut PgConnection,
    states: &[CreditRegistrationState],
    scope: &RegistrationScope,
    limit: i64,
) -> ModelResult<Vec<CreditRegistration>>
Expand description

Claims up to limit due rows in the given states for this worker.

The row locks live until the caller’s transaction ends, so callers must pass a transaction. Rows on a paused course module, or on one whose credit registration has been switched off, are never claimed: enforced here so no phase can forget it. Both freeze a row where it stands rather than cancelling it, so switching the module back on resumes the rows that were already in flight.

An unscoped call (the live background worker) also skips a row whose user (and, if the hold names one, course) has a live row in credit_registration_test_exclusive_holds. A scoped call always ignores holds, so a spec driving its own rows through explicit ticks is unaffected either way.