Skip to content

Exclude removed registrations from leaderboard queries#394

Open
zacjones93 wants to merge 1 commit intomainfrom
claude/filter-leaderboard-registrations-ukAyt
Open

Exclude removed registrations from leaderboard queries#394
zacjones93 wants to merge 1 commit intomainfrom
claude/filter-leaderboard-registrations-ukAyt

Conversation

@zacjones93
Copy link
Copy Markdown
Contributor

@zacjones93 zacjones93 commented Apr 12, 2026

Summary

Updated the leaderboard query to filter out registrations with REMOVED status, ensuring that athletes who have been removed from a competition do not appear in leaderboard standings.

Key Changes

  • Added ne (not equal) operator import from drizzle-orm
  • Imported REGISTRATION_STATUS constant from competitions schema
  • Modified getLeaderboardDataFn to exclude REMOVED registrations in both division-specific and competition-wide queries
  • Updated documentation to clarify that removed registrations are filtered across all downstream queries (leaderboard, heats, divisions, broadcasts, video submissions)

Implementation Details

  • The filter applies to both query paths: when a divisionId is provided and when querying all divisions
  • Uses ne(competitionRegistrationsTable.status, REGISTRATION_STATUS.REMOVED) to exclude removed athletes
  • Maintains consistency with the soft-delete pattern already established in the codebase for registration removal

https://claude.ai/code/session_01Y2QLeDfCv5VJwxXB2N4odj


Summary by cubic

Exclude REMOVED registrations from the legacy leaderboard query so removed athletes never appear in standings. This aligns getLeaderboardDataFn with the main leaderboard and series queries for consistent counts across the app.

  • Bug Fixes
    • Filter REGISTRATION_STATUS.REMOVED using ne from drizzle-orm in division-specific and competition-wide queries.
    • Updated docs to note that leaderboard, heats, divisions, broadcasts, and video submissions exclude removed registrations.

Written for commit a2a058e. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes
    • Removed athletes are now correctly excluded from leaderboard displays and standings calculations.

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

Walkthrough

The leaderboard server function now filters out competition registrations with REMOVED status using ne() constraints in both division-specific and non-division query branches. Documentation is updated to specify this exclusion behavior for all downstream leaderboard and related query paths.

Changes

Cohort / File(s) Summary
Leaderboard Server Function
apps/wodsmith-start/src/server-fns/leaderboard-fns.ts
Added filters to exclude registrations with REGISTRATION_STATUS.REMOVED in both division-specific and event-only branches of the leaderboard query. Updated imports to include ne from drizzle-orm and REGISTRATION_STATUS from the competitions schema.
Registration Documentation
lat.md/registration.md
Updated documentation to specify that leaderboard queries, legacy functions, heats/divisions/broadcasts, and video submissions exclude registrations with REMOVED status.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 Removed athletes hop away,
From leaderboards and standings play,
The filters shine so clean and bright,
Exclusions set the ledger right! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Exclude removed registrations from leaderboard queries' accurately and specifically summarizes the main change: filtering out REMOVED registrations from leaderboard query logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/filter-leaderboard-registrations-ukAyt

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
apps/wodsmith-start/src/server-fns/leaderboard-fns.ts (1)

165-189: Consider moving this registration query into a src/server/ helper.

getLeaderboardDataFn still 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 in lat.md.

As per coding guidelines, "Use wiki links ([[target]] or [[target|alias]]) to cross-reference sections and source code in lat.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

📥 Commits

Reviewing files that changed from the base of the PR and between 6b16404 and a2a058e.

📒 Files selected for processing (2)
  • apps/wodsmith-start/src/server-fns/leaderboard-fns.ts
  • lat.md/registration.md

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

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