feat: sync course filters from MongoDB to MySQL on course publish#143
Merged
Conversation
Add NauCourseFilter model and course_published signal handler to mirror enrollment/certificate filter settings (other_course_settings) into MySQL, so nau-database-exporter can expose them in Looker Studio without MongoDB access. Includes backfill management command and unit tests.
d5dc6a6 to
085caed
Compare
igobranco
approved these changes
May 25, 2026
Member
|
Fixed the conflict. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Course filters for analytics
Summary
This change mirrors enrollment and certificate filter flags from MongoDB (
other_course_settings) into a new MySQL table whenever a course is published in Studio, so nau-database-exporter can expose them in Looker Studio without connecting to MongoDB.Related context: NAU technical proposal / dashboard work (e.g. fccn/nau-technical#635, customer requirement: course filters visible in analytics).
Problem
Filter settings such as domain-based enrollment, NIF requirement, and Portuguese citizen card for certificates live only in MongoDB. The existing exporter reads MySQL only, so dashboards cannot tell which courses are effectively restricted for all learners.
Solution
NauCourseFilter:course_id,filter_type, timestamps;unique_togetheron(course_id, filter_type); one row per active filter.SignalHandler.course_publishedreads normalizedother_course_settings, creates missing rows, deletes rows for filters no longer active. Errors are logged and never block publishing.filter_enrollment_by_domain_list,filter_enrollment_require_nif,certificate_require_portuguese_citizen_card. Override viaNAU_COURSE_FILTER_KEYSfor future filters.sync_course_filters(CMS) for all courses, a single course (--course-id), or resume (--index).Deployment notes
0012_naucoursefilter.python manage.py cms sync_course_filtersonce to backfill historical courses (optionally chunked with--index).NauCourseFilterand add the desired boolean or denormalized columns for Looker Studio.