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,
(cmc.deleted_at IS NOT NULL) AS completion_deleted,
((cmc.deleted_at IS NULL) AND cmc.passed AND cmc.eligible_for_ects AND cmc.prerequisite_modules_completed AND (NOT cmc.needs_to_be_reviewed)) 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 cm.uh_course_code)))))) AS course_code_allowed
FROM (((credit_registrations cr
JOIN course_module_completions cmc ON ((cmc.id = cr.course_module_completion_id)))
JOIN course_modules cm ON ((cm.id = cr.course_module_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_deleted | boolean | true | ||||
| completion_eligible | boolean | true | ||||
| course_code_allowed | boolean | true | False while Suotar’s last verdict on the module’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. | |||
| has_verified_student_number | boolean | 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 |
| cm.uh_course_code | 0 | ||
| public.credit_registrations | 65 | The credit registration ledger: one row per attempt at registering one course module completion into the study registry via Suotar. 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.course_module_completions | 18 | Internal student completions for course modules. | BASE TABLE |
| public.course_modules | 17 | A module is a collection of chapters which can be used to categorise the chapters of a course. | BASE TABLE |
| 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