Modules with a course code and credit_registration_route platform, and enabled mooc.fi targets, that are not paused. The gate every phase that spends work on a unit shares; both ways out of it freeze what is in flight rather than cancelling it, so a query filtering on membership must leave the rows it stops seeing alone.
CREATE VIEW credit_registration_active_units AS (
SELECT cm.id AS credit_unit_id,
cm.course_id,
NULL::uuid AS external_credit_target_id,
cm.uh_course_code
FROM (course_modules cm
LEFT JOIN course_module_suotar_configurations conf ON (((conf.course_module_id = cm.id) AND (conf.deleted_at IS NULL))))
WHERE ((TRIM(BOTH FROM cm.uh_course_code) <> ''::text) AND (cm.credit_registration_route = 'platform'::course_module_credit_registration_route) AND (cm.deleted_at IS NULL) AND (conf.paused_at IS NULL))
UNION ALL
SELECT t.id AS credit_unit_id,
NULL::uuid AS course_id,
t.id AS external_credit_target_id,
t.uh_course_code
FROM external_credit_targets t
WHERE ((t.enabled_at IS NOT NULL) AND (t.paused_at IS NULL) AND (t.deleted_at IS NULL))
)| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| course_id | uuid | true | ||||
| credit_unit_id | uuid | true | ||||
| external_credit_target_id | uuid | true | ||||
| uh_course_code | varchar(255) | true |
| Name | Columns | Comment | Type |
|---|---|---|---|
| public.course_modules | 18 | A module is a collection of chapters which can be used to categorise the chapters of a course. | BASE TABLE |
| 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.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 |
Generated by tbls