Repository navigation
PM-6430 - Update campus leaderboard - fetch challenges in parent group - #166
Conversation
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The new parent_groups CTE resolves only immediate parents while group_tree recurses, so correctness depends on group-hierarchy depth semantics that need human verification against the intended leaderboard behavior.
Review effort: Balanced
Findings: 1
What changed in this PR
This PR updates the campus-leaderboard.sql report so that challenges restricted to a campus group's parent group(s) are also flagged as campus challenges. Previously only challenges restricted to the resolved campus group (and its descendants' identifiers) were counted. The change introduces two new CTEs (parent_groups, campus_groups) and feeds their combined identifiers into the existing group_identifiers set used by the is_campus_challenge flag, aiming for more comprehensive campus reporting.
Changes:
- Added
parent_groupsCTE to resolve the campus group's parent group(s) viaGroupMember. - Added
campus_groupsCTE that unions the root group with its parent group(s), and switchedgroup_identifiersto draw from it. - Updated the header comment to document that parent-group-restricted challenges are flagged as campus challenges.
| File | Description |
|---|---|
| sql/reports/topcoder/campus-leaderboard.sql | Adds parent_groups/campus_groups CTEs and expands the campus challenge identifier set to include parent-group identifiers; updates header comment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| parent_groups AS ( | ||
| SELECT g.id, g."oldId" | ||
| FROM groups."GroupMember" AS gm | ||
| JOIN root_group AS rg | ||
| ON rg.id = gm."memberId" | ||
| JOIN groups."Group" AS g | ||
| ON g.id = gm."groupId" | ||
| WHERE LOWER(gm."membershipType") = 'group' | ||
| ), |

This pull request updates the
campus-leaderboard.sqlreport to improve how campus challenges are identified. It now ensures that challenges restricted to both a campus group and its parent groups are flagged as campus challenges. This change provides a more accurate leaderboard by including all relevant challenges.Campus challenge identification improvements:
parent_groupsandcampus_groupsCTEs to aggregate group IDs from the campus group and its parent groups, and updated subsequent group identifier logic to use this expanded set.