Add series question exclusion feature for competitions#303
Add series question exclusion feature for competitions#303zacjones93 wants to merge 1 commit intomainfrom
Conversation
Add ability for organizers to toggle individual series-level registration questions on/off for specific competitions. This supports the use case where a series defines questions (e.g., shirt size) that don't apply to every competition (e.g., a $20 online comp that doesn't include a shirt). Changes: - Add competition_excluded_series_questions junction table - Add getExcludedSeriesQuestionIdsFn and toggleSeriesQuestionExclusionFn server functions - Update getCompetitionQuestionsFn to filter out excluded series questions - Update validateRequiredQuestions to skip excluded questions - Add Switch toggle UI on competition athletes page for each series question with optimistic updates https://claude.ai/code/session_01NLCnfEt4nVtxfCpJ39n5Hx
|
Warning Rate limit exceeded
⌛ 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. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
✨ 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. Comment |
There was a problem hiding this comment.
1 issue found across 7 files
Prompt for AI agents (all 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-fns/registration-fns.ts">
<violation number="1" location="apps/wodsmith-start/src/server-fns/registration-fns.ts:178">
P2: The exclusion filter removes any required question by ID, including competition-specific questions. That can let required competition questions be skipped if their IDs are mistakenly added to the exclusion table. Limit exclusions to series-level questions only.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| const activeRequiredQuestions = requiredQuestions.filter( | ||
| (q) => !excludedIds.has(q.id), | ||
| ) |
There was a problem hiding this comment.
P2: The exclusion filter removes any required question by ID, including competition-specific questions. That can let required competition questions be skipped if their IDs are mistakenly added to the exclusion table. Limit exclusions to series-level questions 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-fns/registration-fns.ts, line 178:
<comment>The exclusion filter removes any required question by ID, including competition-specific questions. That can let required competition questions be skipped if their IDs are mistakenly added to the exclusion table. Limit exclusions to series-level questions only.</comment>
<file context>
@@ -141,26 +144,47 @@ async function validateRequiredQuestions(
+ // Filter out excluded series questions
+ const excludedIds = new Set(excludedRows.map((r) => r.questionId))
+ const activeRequiredQuestions = requiredQuestions.filter(
+ (q) => !excludedIds.has(q.id),
+ )
</file context>
| const activeRequiredQuestions = requiredQuestions.filter( | |
| (q) => !excludedIds.has(q.id), | |
| ) | |
| const activeRequiredQuestions = requiredQuestions.filter( | |
| (q) => | |
| !( | |
| q.groupId && | |
| !q.competitionId && | |
| excludedIds.has(q.id) | |
| ), | |
| ) |
…riesSettingsTable Replace the narrow competitionExcludedSeriesQuestionsTable from PR #303 with a generalized competitionExcludedSeriesSettingsTable that supports excluding any type of series-inherited setting (registration questions, waivers, etc.) via a settingType discriminator column. This avoids needing separate exclusion tables per setting type. - Add competitionExcludedSeriesSettingsTable with (competitionId, settingType, settingId) - Add SERIES_SETTING_TYPES constant with REGISTRATION_QUESTION and WAIVER - Add getExcludedSeriesQuestionIdsFn and toggleSeriesQuestionExclusionFn server functions - Update getCompetitionQuestionsFn to filter out excluded series questions - Update validateRequiredQuestions to skip excluded series questions - Add Switch UI component and series question toggle controls on organizer athletes page https://claude.ai/code/session_01RUHL6Z3Nv8PSBhFsK7o26U
Summary
This PR adds the ability for competition organizers to selectively exclude inherited series-level registration questions from specific competitions. Previously, all series questions were automatically included in every competition within that series.
Key Changes
Database Schema
competitionExcludedSeriesQuestionsTableto track which series questions are excluded from specific competitionsServer Functions
New functions:
getExcludedSeriesQuestionIdsFn: Retrieves excluded question IDs for a competition (requires MANAGE_PROGRAMMING permission)toggleSeriesQuestionExclusionFn: Toggles a series question's exclusion status for a competitionUpdated functions:
getCompetitionQuestionsFn: Now filters out excluded series questions when fetching questions for a competitionvalidateRequiredQuestions: Excludes validation for questions that are marked as excluded for the competitionUI Components
Switchcomponent (Radix UI) for toggle controlsData Loading
Implementation Details
https://claude.ai/code/session_01NLCnfEt4nVtxfCpJ39n5Hx
Summary by cubic
Added per-competition toggles to include/exclude series-level registration questions. Excluded questions are hidden during registration and skipped in validation.
New Features
Migration
Written for commit b00ed6a. Summary will update on new commits.