Index

public.external_completions

Description

A mooc.fi completion as courses last read it, one row per completion and the target its tier maps to. The subject of a mooc.fi ledger row, as course_module_completions is of a native one. Facts are copied from mooc.fi when the student opens the registration page and on re-check; mooc.fi stays the source of truth.

Columns

Name Type Default Nullable Children Parents Comment
completion_date timestamp with time zone false The effective completion date: mooc.fi’s completion_date, or its created_at when that is NULL, as mooc.fi’s pull cutoff reads it.
completion_language varchar(15) true The completion language in mooc.fi’s form, such as fi_FI. NULL when mooc.fi has none.
created_at timestamp with time zone now() false Timestamp when the record was created.
deleted_at timestamp with time zone true Timestamp when the record was deleted. If null, the record is not deleted.
eligible_for_ects boolean false mooc.fi’s eligible_for_ects, with NULL stored as false.
external_credit_target_id uuid false public.external_credit_targets The target whose tier range admitted the completion when it was read. A tier later moved out of that range withdraws the row, and the completion gets a new row under the target now covering it.
grade integer true The numeric grade 0 to 5, NULL for a pass/fail or unrecognised grade.
id uuid uuid_generate_v4() false public.credit_registration_enrolment_check_signals public.credit_registration_enrolment_routes public.credit_registrations public.moocfi_outbound_handoffs A unique, stable identifier for the record.
moocfi_completion_id uuid false The completion’s id on mooc.fi, which report-back registers.
moocfi_user_upstream_id integer false The student’s TMC user id, the key of the mooc.fi completion lookup. Stored so re-checks need no user token.
passed boolean true Whether the parsed grade is a pass. NULL when the grade was not recognised, which keeps the row from registering until it is fixed on mooc.fi.
raw_grade text true mooc.fi’s grade verbatim, a free string there, for the admin view. passed and grade are parsed from it.
registered_upstream_at timestamp with time zone true When a registration of the completion by another mooc.fi organization was first seen. Withdraws the row: someone else registered it.
reported_at timestamp with time zone true When a registration of the completion by our organization was first on mooc.fi, reported by us or found there. Set once. Keeps a completion registered before delegation from getting a ledger row, though not one whose tier moved after we registered it under another target; which registrations were reported is in moocfi_registration_reports.
revised_at timestamp with time zone now() false When the completion’s facts as read from mooc.fi (date, language, tier, eligibility or grade) last changed. Unlike updated_at, not moved by a re-check that finds nothing new. The grade-improvement scan compares against it, through credit_registration_subjects.revised_at.
tier integer true The completion tier on a tiered course, NULL otherwise.
updated_at timestamp with time zone now() false Timestamp when the record was last updated. The field is updated automatically by the set_timestamp trigger.
upstream_check_failed_at timestamp with time zone true When moocfi-recheck last failed to read the completion from mooc.fi. Counts as a check for when to try again, so a lookup that keeps failing waits its turn instead of crowding out the others.
upstream_checked_at timestamp with time zone false When mooc.fi last returned this completion. Import refuses a row whose check is too old.
upstream_missing_at timestamp with time zone true When the lookup first stopped returning the completion, meaning it was deleted on mooc.fi. Cleared if it reappears. Withdraws the row while set.
user_id uuid false public.users The courses account of the student, matched to mooc.fi by users.upstream_id.

Constraints

Name Type Definition
external_completions_completion_date_not_null n NOT NULL completion_date
external_completions_created_at_not_null n NOT NULL created_at
external_completions_eligible_for_ects_not_null n NOT NULL eligible_for_ects
external_completions_external_credit_target_id_fkey FOREIGN KEY FOREIGN KEY (external_credit_target_id) REFERENCES external_credit_targets(id)
external_completions_external_credit_target_id_not_null n NOT NULL external_credit_target_id
external_completions_grade_check CHECK CHECK (((grade >= 0) AND (grade <= 5)))
external_completions_grade_needs_passed CHECK CHECK (((passed IS NOT NULL) OR (grade IS NULL)))
external_completions_id_not_null n NOT NULL id
external_completions_moocfi_completion_id_not_null n NOT NULL moocfi_completion_id
external_completions_moocfi_user_upstream_id_not_null n NOT NULL moocfi_user_upstream_id
external_completions_pkey PRIMARY KEY PRIMARY KEY (id)
external_completions_revised_at_not_null n NOT NULL revised_at
external_completions_updated_at_not_null n NOT NULL updated_at
external_completions_upstream_checked_at_not_null n NOT NULL upstream_checked_at
external_completions_user_id_fkey FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users(id)
external_completions_user_id_not_null n NOT NULL user_id

Indexes

Name Definition
external_completions_pkey CREATE UNIQUE INDEX external_completions_pkey ON public.external_completions USING btree (id)
idx_external_completions_user_target CREATE INDEX idx_external_completions_user_target ON public.external_completions USING btree (user_id, external_credit_target_id) WHERE (deleted_at IS NULL)
uq_external_completions_completion_target CREATE UNIQUE INDEX uq_external_completions_completion_target ON public.external_completions USING btree (moocfi_completion_id, external_credit_target_id) WHERE (deleted_at IS NULL)

Triggers

Name Definition
set_timestamp CREATE TRIGGER set_timestamp BEFORE UPDATE ON public.external_completions FOR EACH ROW EXECUTE FUNCTION trigger_set_timestamp()

Relations

er

Generated by tbls