Skip to main content

Module credit_registration_roster_schedules

Module credit_registration_roster_schedules 

Source
Expand description

When enrolment discovery fetches each course code’s enrolment list.

A code is due weekly, and sooner while somebody on its modules waits for a student number: each such person is on the ladders of the signals they have given that they are enrolling, and the code is due at the earliest rung no fetch that could claim linking mail has served. Every due time snaps up to the code’s own grid, see fetch_slot, so codes spread evenly over the hour. Both are derived whenever they are needed; the table keeps only what cannot be: when fetches ran, the failure backoff and how many fetches of the code went out today.

Modules§

testing
Test-mode setup the system tests drive through the mock Suotar control routes.

Structs§

AccountLinkingCodeCounters
What one code’s last enrolment list that fed account linking did, each person counted once in exactly one of the counters after listed_person_count. Written whole, so the dashboard never mixes two runs.
CodeWaiting 🔒
The people waiting on one code; see RosterSchedule.
FailingRosterCode
Codes listed on their own that keep failing, for the admin alert.
RosterSchedule
One code’s schedule, with the waiting people its next fetch is derived from.

Enums§

ScheduleSelection
Which codes get_schedules reads.

Constants§

ALONE_FAILURE_BACKOFF_SECS 🔒
How long a code that failed on its own is left alone, by how many times in a row it has.
BASELINE_INTERVAL
How often every code is fetched, whether or not anybody on it is waiting.
FETCH_GRID_STEP
How far apart the points of a code’s fetch grid are. Divides an hour.
MAX_FETCHES_PER_DAY
How many fetches of one code may go out in a UTC day. Past it, only the weekly fetch and an admin’s request make the code due: a third of the grid points, so one busy code cannot crowd out the rest.
MIN_REFETCH_GAP
A code fetched this recently is not fetched again, whatever is due.
PRESSED_LADDER 🔒
PRESS_MIN_REFETCH_GAP
The shorter gap the first fetch after an “I have enrolled” press or an admin’s request needs, since somebody is waiting on it.
VISITED_LADDER 🔒
WAITING_HORIZON
How long after its anchor a waiting person still makes the code due: every ladder ends here.
WAITING_HORIZON_SECS 🔒

Functions§

ensure_rows
Creates the schedule rows of every listable code, and the per-module configuration rows the listing status is written to. course_id narrows it to one course.
fetch_slot
The first point of course_code’s fetch grid at or after at: FETCH_GRID_STEP apart, at an offset into the step fixed per code. The only place that decides when within the hour a code goes out.
get_failing_codes
The codes whose latest listings failed, most consecutive failures first.
get_modules_by_code
The active modules on each of course_codes, which share its roster. course_id narrows them to one course, as it does for get_schedules.
get_schedules
Every listable code that has a schedule row; see ensure_rows. course_id narrows the codes and the modules their waiting people come from to one course, for a scoped tick. Only completions on or after account_linking_since can wait, and with it None nobody does.
get_waiting 🔒
The people waiting on each code, their rungs and presses counted after the code’s served_until.
mark_alone_failed
Records a listing of the code on its own that failed, and backs the code off: an hour, four hours, then daily.
mark_attempted
Stamps the codes a listing request is about to go out for and counts the fetch against MAX_FETCHES_PER_DAY. Returns the stamp to hand to mark_fetched.
mark_batch_failed
Records a request batching several codes that failed as a whole. Each is listed on its own from now on, until it succeeds, so one bad code stops failing the others.
mark_fetched
Records an enrolment list that arrived, or Suotar saying it holds no realisation of the code, and clears the failure streak. started_at is what mark_attempted returned for the request, and could_claim_mail whether the list was free to claim linking mail; only such a fetch serves the waiting people’s rungs and presses. Returns when the code was fetched before this.
record_linking_counters
Overwrites the code’s linking counters with what its latest enrolment list did. unlinked_enrolled_before_count counts the people the list held outside the counters: enrolled before account linking began, and linked to no account.
request_fetch
Makes the code due at its next grid point, past MAX_FETCHES_PER_DAY. Returns the schedule row’s id, or None for a code with no row.