The things one ledger row waits on, as they stand right now. The ledger records only that a row is pending, so this is where every surface that names the blocker, and the precondition recompute that acts on it, read the same answer.
CREATE VIEW credit_registration_preconditions AS (
SELECT cr.id AS credit_registration_id,
s.is_withdrawn,
((NOT s.is_withdrawn) AND s.fully_eligible) AS completion_eligible,
(vsn.id IS NOT NULL) AS has_verified_student_number,
((cr.student_number IS NOT NULL) AND (((vsn.student_number)::text IS DISTINCT FROM (cr.student_number)::text) OR ((vsn.sisu_person_id)::text IS DISTINCT FROM (cr.sisu_person_id)::text))) AS frozen_identity_stale,
((NOT (EXISTS ( SELECT 1
FROM course_module_suotar_configurations conf
WHERE ((conf.course_module_id = cr.course_module_id) AND (conf.deleted_at IS NULL) AND (NOT conf.course_code_allowed) AND ((conf.checked_course_code)::text = TRIM(BOTH FROM s.uh_course_code)))))) AND (NOT (EXISTS ( SELECT 1
FROM external_credit_targets t
WHERE ((t.id = cr.external_credit_target_id) AND (NOT t.course_code_allowed) AND ((t.checked_course_code)::text = TRIM(BOTH FROM t.uh_course_code))))))) AS course_code_allowed,
(s.passed IS NULL) AS grade_unrecognised,
s.subject_id
FROM ((credit_registrations cr
JOIN credit_registration_subjects s ON ((s.subject_id = cr.subject_id)))
LEFT JOIN verified_student_numbers vsn ON (((vsn.user_id = cr.user_id) AND (vsn.deleted_at IS NULL))))
)| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| completion_eligible | boolean | true | ||||
| course_code_allowed | boolean | true | False while Suotar’s last verdict on the unit’s current course code says it does not accept it; true once it does, or when there is no verdict. Rows wait in pending while false, since every import would come back courseNotAllowed. | |||
| credit_registration_id | uuid | true | ||||
| frozen_identity_stale | boolean | true | The account has relinked to a different verified student number since this row froze its payload for import. A relink soft-deletes and re-inserts in one transaction, so has_verified_student_number stays true throughout and catches none of it. | |||
| grade_unrecognised | boolean | true | The mooc.fi grade could not be parsed, so completion_eligible is false until it is fixed on mooc.fi. Always false for a course module completion. | |||
| has_verified_student_number | boolean | true | ||||
| is_withdrawn | boolean | true | See credit_registration_subjects.is_withdrawn. | |||
| subject_id | uuid | true |
| Name | Columns | Comment | Type |
|---|---|---|---|
| cr.student_number | 0 | ||
| cr.sisu_person_id | 0 | ||
| public.course_module_suotar_configurations | 17 | Per-module Suotar credit registration configuration, the per-module pause, and the config-validation phase’s last verdict. At most one live row per course module; no row means the module is not configured, which is not an error. | BASE TABLE |
| s.uh_course_code | 0 | ||
| public.external_credit_targets | 29 | A mooc.fi course whose credits courses registers into the study registry, standing in for both course_modules and course_module_suotar_configurations for mooc.fi ledger rows. Each tier of a course maps to at most one live target, enforced by the external_credit_targets_tier_overlap trigger, so a completion registers one course code per tier it has had. | BASE TABLE |
| t.uh_course_code | 0 | ||
| public.credit_registrations | 69 | The credit registration ledger: one row per attempt at registering one completion into the study registry via Suotar, either a course module completion or a mooc.fi completion (external_completions). Every state write goes through credit_registrations::transition, which stamps state_entered_at and appends an event row in the same transaction; nothing else may update state. | BASE TABLE |
| public.credit_registration_subjects | 27 | Every completion a ledger row can register, course module completions and mooc.fi completions alike, with the facts of the completion and of the unit (module or target) it registers for. Ledger rows join it on subject_id. | VIEW |
| public.verified_student_numbers | 15 | Student numbers proven to belong to a courses.mooc.fi account. Global per account: one live row per user, one per student number and one per Sisu person id. Relinking soft-deletes the old row and inserts a new one; student_number is never updated in place because the old value is audit-relevant. | BASE TABLE |
Generated by tbls