Exclude removed registrations from leaderboard queries#394
Exclude removed registrations from leaderboard queries#394zacjones93 wants to merge 1 commit intomainfrom
Conversation
The legacy getLeaderboardDataFn pulled all registrations for a competition without filtering REMOVED ones, so athletes removed by organizers would still appear on any surface that called it. The main getCompetitionLeaderboard and getSeriesLeaderboard already excluded REMOVED registrations; this brings the legacy path in line.
WalkthroughThe leaderboard server function now filters out competition registrations with Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/wodsmith-start/src/server-fns/leaderboard-fns.ts (1)
165-189: Consider moving this registration query into asrc/server/helper.
getLeaderboardDataFnstill contains inline business/data-access logic. Extracting this query path to the server layer would better match the repo’s function-boundary pattern.As per coding guidelines, "Use helper functions in
src/server/for business logic instead of inline database queries".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/wodsmith-start/src/server-fns/leaderboard-fns.ts` around lines 165 - 189, Extract the inline DB query out of getLeaderboardDataFn into a server helper function (e.g., getCompetitionRegistrations) that accepts (db, competitionId, divisionId) and returns the registrations; move the db.query.competitionRegistrationsTable.findMany call (including the conditional where with eq/ne, the with: { user, division }, and orderBy using regs.registeredAt) into that helper, preserve usage of competitionRegistrationsTable and REGISTRATION_STATUS, export the helper from the server layer and replace the inline query in getLeaderboardDataFn with a call to getCompetitionRegistrations(db, data.competitionId, data.divisionId).lat.md/registration.md (1)
89-89: Add wiki links for all referenced query paths in this sentence.This line names several downstream paths but only links one symbol. Please convert the other references to
[[...]]links for consistent navigability inlat.md.As per coding guidelines, "Use wiki links (
[[target]]or[[target|alias]]) to cross-reference sections and source code inlat.md/files".🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lat.md/registration.md` at line 89, The sentence currently links only getLeaderboardDataFn; update it so every referenced downstream query is a wiki link: wrap "competition leaderboard", "series leaderboard", "heats", "divisions", "broadcasts", and "video submissions" in [[...]] wiki links (use the same linking style as the existing [[apps/wodsmith-start/src/server-fns/leaderboard-fns.ts#getLeaderboardDataFn]] link, adding aliases like [[competition leaderboard|competition leaderboard]] if needed) so all six targets become navigable consistent wiki links.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@apps/wodsmith-start/src/server-fns/leaderboard-fns.ts`:
- Around line 165-189: Extract the inline DB query out of getLeaderboardDataFn
into a server helper function (e.g., getCompetitionRegistrations) that accepts
(db, competitionId, divisionId) and returns the registrations; move the
db.query.competitionRegistrationsTable.findMany call (including the conditional
where with eq/ne, the with: { user, division }, and orderBy using
regs.registeredAt) into that helper, preserve usage of
competitionRegistrationsTable and REGISTRATION_STATUS, export the helper from
the server layer and replace the inline query in getLeaderboardDataFn with a
call to getCompetitionRegistrations(db, data.competitionId, data.divisionId).
In `@lat.md/registration.md`:
- Line 89: The sentence currently links only getLeaderboardDataFn; update it so
every referenced downstream query is a wiki link: wrap "competition
leaderboard", "series leaderboard", "heats", "divisions", "broadcasts", and
"video submissions" in [[...]] wiki links (use the same linking style as the
existing
[[apps/wodsmith-start/src/server-fns/leaderboard-fns.ts#getLeaderboardDataFn]]
link, adding aliases like [[competition leaderboard|competition leaderboard]] if
needed) so all six targets become navigable consistent wiki links.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: c07b7189-14c2-4898-990b-e1638bd3e172
📒 Files selected for processing (2)
apps/wodsmith-start/src/server-fns/leaderboard-fns.tslat.md/registration.md
Summary
Updated the leaderboard query to filter out registrations with
REMOVEDstatus, ensuring that athletes who have been removed from a competition do not appear in leaderboard standings.Key Changes
ne(not equal) operator import fromdrizzle-ormREGISTRATION_STATUSconstant from competitions schemagetLeaderboardDataFnto excludeREMOVEDregistrations in both division-specific and competition-wide queriesImplementation Details
divisionIdis provided and when querying all divisionsne(competitionRegistrationsTable.status, REGISTRATION_STATUS.REMOVED)to exclude removed athleteshttps://claude.ai/code/session_01Y2QLeDfCv5VJwxXB2N4odj
Summary by cubic
Exclude
REMOVEDregistrations from the legacy leaderboard query so removed athletes never appear in standings. This alignsgetLeaderboardDataFnwith the main leaderboard and series queries for consistent counts across the app.REGISTRATION_STATUS.REMOVEDusingnefromdrizzle-ormin division-specific and competition-wide queries.Written for commit a2a058e. Summary will update on new commits.
Summary by CodeRabbit