Add per-division global spots override for series sources - #433
Add per-division global spots override for series sources#433zacjones93 wants to merge 1 commit into
Conversation
…rces Series sources now support per-division overrides on the global-leaderboard portion (e.g. 3 RX globals, 2 Scaled globals) in addition to the existing absolute-total override. Both axes live on the same allocation row keyed by (sourceId, championshipDivisionId); the source details page stacks a new "Per-division global spots" card above the existing per-division allocation table for series sources, mirroring the same Use-default + numeric-input UX. The resolver applies precedence per row: spots non-null → absolute total override; else globalSpots non-null → directSpotsPerComp*compCount + globalSpots; else → source default. Single-comp sources are unchanged in practice (UI only exposes the new card for series).
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (8)
✨ Finishing Touches🧪 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. Review rate limit: 0/1 reviews remaining, refill in 59 minutes and 56 seconds.Comment |
There was a problem hiding this comment.
2 issues found across 8 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/wodsmith-start/src/server/competition-invites/allocations.ts">
<violation number="1" location="apps/wodsmith-start/src/server/competition-invites/allocations.ts:69">
P2: `globalSpots` row overrides are being applied to competition sources even though this override is intended to be series-only.</violation>
</file>
<file name="apps/wodsmith-start/src/routes/compete/organizer/$competitionId/invites/sources/$sourceId.tsx">
<violation number="1" location="apps/wodsmith-start/src/routes/compete/organizer/$competitionId/invites/sources/$sourceId.tsx:398">
P2: Each save action is coupled to both override sections, so saving one card can validate and persist unsaved changes from the other card.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const globalSpots = globalSpotsOverride ?? source.globalSpots ?? 0 | ||
| if (source.kind === COMPETITION_INVITE_SOURCE_KIND.SERIES) { | ||
| const direct = source.directSpotsPerComp ?? 0 | ||
| const compCount = seriesCompCount ?? 0 |
There was a problem hiding this comment.
P2: globalSpots row overrides are being applied to competition sources even though this override is intended to be series-only.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/wodsmith-start/src/server/competition-invites/allocations.ts, line 69:
<comment>`globalSpots` row overrides are being applied to competition sources even though this override is intended to be series-only.</comment>
<file context>
@@ -55,12 +55,18 @@ export interface ResolvedSourceAllocations {
+ globalSpotsOverride: number | null,
): number {
- const globalSpots = source.globalSpots ?? 0
+ const globalSpots = globalSpotsOverride ?? source.globalSpots ?? 0
if (source.kind === COMPETITION_INVITE_SOURCE_KIND.SERIES) {
const direct = source.directSpotsPerComp ?? 0
</file context>
| }) | ||
| } | ||
| setGlobalSpotsError(null) | ||
| const { payload, error } = buildAllocationPayload() |
There was a problem hiding this comment.
P2: Each save action is coupled to both override sections, so saving one card can validate and persist unsaved changes from the other card.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/wodsmith-start/src/routes/compete/organizer/$competitionId/invites/sources/$sourceId.tsx, line 398:
<comment>Each save action is coupled to both override sections, so saving one card can validate and persist unsaved changes from the other card.</comment>
<file context>
@@ -264,42 +394,17 @@ function InviteSourceDetailsPage() {
- })
- }
+ setGlobalSpotsError(null)
+ const { payload, error } = buildAllocationPayload()
+ if (error) {
+ setAllocationError(error)
</file context>
Summary
Extends the per-division allocation system to support independent overrides of the global-leaderboard contribution for series sources, while preserving the existing absolute-spots override behavior. This allows organizers to tune how many global-leaderboard qualifiers each division receives from a series (e.g., 3 RX, 2 Scaled) without affecting the per-competition direct tier.
Key Changes
New
globalSpotscolumn incompetitionInviteSourceDivisionAllocationsTable: Stores per-division global-leaderboard overrides for series sources, nullable to indicate "use source default"Dual-axis override model: Each allocation row now carries two independent nullable axes:
spots: Absolute total override (existing behavior, takes precedence)globalSpots: Series-only per-division global-leaderboard override (new)Updated resolver logic (
resolveSourceAllocations): Implements precedence rules:spotsis non-null → return it directlyglobalSpotsis non-null (series only) → returndirectSpotsPerComp * seriesCompCount + globalSpotsNew UI card in invite source details page: "Per-division global spots" card (series sources only) with:
Updated schema documentation: Clarified the two-axis model and precedence rules in comments and ADR notes
Test coverage: Added four new test cases covering global-spots overrides, zero values, precedence with absolute-spots overrides, and fallback behavior
Implementation Details
buildAllocationPayload()helper constructs a merged payload containing bothspotsandglobalSpotsfor each division, ensuring that saving from either card doesn't accidentally clear the other axisisSeriesSource) gates the global-spots UI and validation logichttps://claude.ai/code/session_01EnVk9h1h8GhuF8dUddRD7u
Summary by cubic
Adds per-division global spots overrides for series sources so organizers can set how many global-leaderboard qualifiers each division gets without changing per-comp direct spots. Updates schema, resolver, API, and UI to support a dual-axis override model.
New Features
globalSpotstocompetitionInviteSourceDivisionAllocationsTable;spotsis now nullable.spots(absolute total) andglobalSpots(series-only global tier).resolveSourceAllocationsprecedence:spots>globalSpots(series) > source default.listInviteSourceAllocationsFn,saveInviteSourceAllocationsFn) now read/write both axes and send merged payloads to avoid clearing the other axis; added tests for overrides, zero values, precedence, and fallbacks.Migration
globalSpotsand makespotsnullable oncompetitionInviteSourceDivisionAllocationsTable.saveInviteSourceAllocationsFn.Written for commit f9a67c1. Summary will update on new commits. Review in cubic