Skip to main content

Module verified_student_numbers

Module verified_student_numbers 

Source

Structs§

AdminPageRow ðŸ”’
A row with the page’s total attached, so a page and its count can only come from one query.
AdminVerifiedStudentNumber
One link as an admin support view shows it, with the account it belongs to.
NewVerifiedStudentNumber
VerifiedStudentNumber

Enums§

LinkConflict
Whose live link already holds a student number or its Sisu person, from the point of view of user_id about to link them.
StudentNumberVerificationMethod
How a student number was proven to belong to an account.

Functions§

count_by_method_since
Live links per method, both all-time and since a cutoff, in one pass over the table, so an admin-established one is never hidden inside a total.
count_unlinked_enrolled_students_for_course
Enrolled students of the course who hold no live student number link, and so cannot have credits registered for them until they link one.
fill_sisu_person_id
Gives a live link that has no Sisu person id yet the one the registry resolved its number to, along with the registry’s names where the link has none.
find_link_conflict
Checks both unique keys before linking: a student who changed programme keeps their Sisu person id and gets a new number, so checking the number alone lets the link through and then trips uq_verified_student_numbers_person as a bare 500. Another account’s hold wins over our own.
get_admin_page
Live links only, newest first: a retired link is not a number we hold. Returns the page together with how many rows match the filters in total, from one query via COUNT(*) OVER().
get_by_id
get_by_sisu_person_id
The live link for one Sisu person. Unique alongside the student number, so a programme change that issues a new number still collides here.
get_by_sisu_person_ids
The person id rather than the number, because the number changes when a student moves between programmes while the person id does not.
get_by_student_number
get_by_student_numbers
get_by_user_id
The account’s live link, if it has one. At most one exists by partial unique index.
get_by_user_ids
get_latest_including_deleted_by_user_id
The account’s most recent link, retired ones included: a retired link is the only record an unlinked account has of the Sisu person its linking mail was addressed to.
get_latest_including_deleted_by_user_ids
Batched form of get_latest_including_deleted_by_user_id, one row per account.
insert
link_numbers_reported_by_study_registry
Links each of user_ids to the student number a registrar last reported for them, as a StudentNumberVerificationMethod::StudyRegistry link, and records a conflict wherever a live link still stands in the way. A link someone made by hand (the student or an admin) always wins, but another account’s study-registry link on the reported number moves to the account reported most recently, unless the holder’s own report of it is newer: a student with two accounts gets the number on the later one. A retired link does not block: the registrar’s report is authoritative, so a number the student or an admin unlinked, or one resolve-person-ids dropped over a conflict, is linked again. Returns how many links were made.
replace_verified_student_number
Retires current_link_id (the account’s link the caller already resolved, if any), inserts new in its place, clears the mailed links to new’s number that are no longer owed, and audits the change on the account’s live registrations.
soft_delete
Unlinks by soft-delete; relinking inserts a new row, keeping the old number for audit.