Skip to content

Fix duplicate engagement rows from non-unique course_number join in mitxonline_course_engagements_daily_report#1918

Merged
quazi-h merged 2 commits into
mitxonline-course-engagements-daily-reportfrom
copilot/sub-pr-1906
Feb 20, 2026
Merged

Fix duplicate engagement rows from non-unique course_number join in mitxonline_course_engagements_daily_report#1918
quazi-h merged 2 commits into
mitxonline-course-engagements-daily-reportfrom
copilot/sub-pr-1906

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 20, 2026

int__mitx__courses is not guaranteed unique on course_number (e.g. UAI courses), so joining directly on that field could fan out engagement rows and inflate metrics.

Changes

  • Added mitxonline_course_runs CTE sourced from int__mitxonline__course_runs to bridge engagements → integer course ID
  • Replaced course_number join with mitxonline_course_id — a unique integer FK — eliminating the duplication risk
-- Before: ambiguous, potentially multi-row match
left join mitx_courses
    on mitxonline_engagements.course_number = mitx_courses.course_number

-- After: precise 1:1 join via integer PK
inner join mitxonline_course_runs
    on mitxonline_engagements.courserun_readable_id = mitxonline_course_runs.courserun_readable_id
left join mitx_courses
    on mitxonline_course_runs.course_id = mitx_courses.mitxonline_course_id

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…to avoid duplicates

Co-authored-by: quazi-h <59845076+quazi-h@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback on mitxonline course engagements daily report PR Fix duplicate engagement rows from non-unique course_number join in mitxonline_course_engagements_daily_report Feb 20, 2026
Copilot AI requested a review from quazi-h February 20, 2026 18:44
@quazi-h quazi-h marked this pull request as ready for review February 20, 2026 18:55
@quazi-h quazi-h merged commit bf52232 into mitxonline-course-engagements-daily-report Feb 20, 2026
2 checks passed
@quazi-h quazi-h deleted the copilot/sub-pr-1906 branch February 20, 2026 18:56
quazi-h added a commit that referenced this pull request Feb 27, 2026
…itxonline_course_engagements_daily_report (#1918)

* Initial plan
* Fix course join to use mitxonline_course_id instead of course_number to avoid duplicates
Co-authored-by: quazi-h <59845076+quazi-h@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: quazi-h <59845076+quazi-h@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants