Skip to content

Fix page_engagement_views_report: correct uniqueness test grain and platform user joins#1938

Closed
Copilot wants to merge 2 commits intopage-engagement-views-reportfrom
copilot/sub-pr-1915
Closed

Fix page_engagement_views_report: correct uniqueness test grain and platform user joins#1938
Copilot wants to merge 2 commits intopage-engagement-views-reportfrom
copilot/sub-pr-1915

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 23, 2026

page_engagement_views_report had two correctness issues: the dim_user join only matched mitxonline users, dropping all others, and the uniqueness test used unit_title which is not unique across blocks (two verticals in the same course can share the same title).

Changes

  • Multi-platform user join: replaced single mitxonline_openedx_user_id join with platform-conditional OR join covering mitxonline, edxorg, mitxpro, and residential
  • Block category filters: added block_category = 'sequential' to subsection_blocks CTE and block_category = 'chapter' to section_blocks CTE to avoid cross-block-type join pollution
  • Removed unnecessary GROUP BY: int__combined__course_runs already has unique courserun_readable_id; the aggregation was pure overhead
  • Fixed uniqueness test grain: added unit_block_id (unit_blocks.block_id) to the SELECT and switched the compound uniqueness test from unit_title to unit_block_id, which is the actual surrogate key for the block
-- Before: fails when two verticals share a title
["user_email", "courserun_readable_id", "unit_title"]

-- After: reflects true grain of the data
["user_email", "courserun_readable_id", "unit_block_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.

…on shared block titles

Co-authored-by: quazi-h <59845076+quazi-h@users.noreply.github.com>
Copilot AI changed the title [WIP] Add page engagement views report model Fix page_engagement_views_report: correct uniqueness test grain and platform user joins Feb 23, 2026
Copilot AI requested a review from quazi-h February 23, 2026 14:07
@quazi-h
Copy link
Copy Markdown
Contributor

quazi-h commented Mar 2, 2026

@copilot is this PR still relevant to the branch it is being merged into?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 2, 2026

@copilot is this PR still relevant to the branch it is being merged into?

No, this PR is no longer relevant. The base branch (page-engagement-views-report) already has commit 4a596719 ("Fix multiple issues in page_engagement_views_report") from @quazi-h that independently addressed the same Sentry uniqueness test bug this PR was created to fix — using block_fk (directly from the fact table) rather than a new unit_block_id column.

Additionally, merging this PR as-is would be harmful: it would delete the problem_engagement_detail_report model documentation that was added to _reporting__models.yml in commit f543d4fe.

This PR can be closed.

@quazi-h quazi-h closed this Mar 4, 2026
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