Conversation
WalkthroughThe changes add seeding support for contest-task pair relationships in Prisma seeds. A new data module defines contest_task_pairs records, seed.ts implements concurrent seeding logic with factory patterns and deduplication, tasks.ts expands with new problem entries, and plan.md documents the implementation strategy. Changes
Sequence DiagramsequenceDiagram
participant main as main()
participant addCP as addContestTaskPairs()
participant factory as contestTaskPairFactory
participant queue as PQueue
participant db as prisma.contestTaskPair
main->>addCP: await addContestTaskPairs()
activate addCP
addCP->>factory: defineContestTaskPairFactory()
addCP->>queue: new PQueue({concurrency: N})
loop for each contest_task_pair in data
addCP->>db: findUnique({contestId, taskId})
alt record exists
addCP->>queue: queue add (skip)
else record missing
addCP->>queue: queue add(() => addContestTaskPair())
activate queue
queue->>factory: create(fields)
factory->>db: prisma.contestTaskPair.create()
db-->>factory: ✓ created
queue->>addCP: log success
deactivate queue
end
end
addCP->>queue: await queue.onIdle()
addCP-->>main: ✓ done
deactivate addCP
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes The seed.ts changes introduce new concurrency patterns with PQueue integration, factory-based record creation, idempotent deduplication logic, and error handling. While tasks.ts and contest_task_pairs.ts are straightforward data additions, the primary complexity stems from seed.ts requiring verification of queue management, factory invocation correctness, and proper integration with existing seeding architecture. Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
docs/dev-notes/2025-10-22/add-contest-task-pairs-to-seeds/plan.md (1)
92-100: Doc/code drift: key names and field names
- Code uses prisma.contestTaskPair.findUnique({ where: { contestId_taskId: { contestId, taskId } } }), but the doc shows contest_id_task_id and pair.task_id. Please update to contestId_taskId and pair.problem_id to match the current implementation (or standardize the data field to task_id project-wide and adjust code accordingly).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (4)
docs/dev-notes/2025-10-22/add-contest-task-pairs-to-seeds/plan.md(1 hunks)prisma/contest_task_pairs.ts(1 hunks)prisma/seed.ts(5 hunks)prisma/tasks.ts(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: preview
🔇 Additional comments (8)
prisma/tasks.ts (3)
4008-4014: abc007_3 addition looks goodEntry structure is consistent and it’s referenced in contest_task_pairs. LGTM.
4718-4766: New math-and-algorithm entries added correctlyIDs, contest_id, and problem_index align with contest_task_pairs. LGTM.
4775-4788: math_and_algorithm_ac and _o addedBoth are referenced by contest_task_pairs; fields look consistent. LGTM.
prisma/seed.ts (5)
14-14: Factory import LGTM
30-30: Data import LGTM
47-47: Added concurrency knob LGTMDefault and env override pattern matches existing knobs.
65-66: Seeding order updatedPlacing addContestTaskPairs() after addTasks() is correct. LGTM.
221-231: Field mapping in create() looks correctcontestId, taskTableIndex, taskId match the data file. LGTM.
If you standardize data to task_id later, remember to update pair.problem_id usages here.
close #2734
Summary by CodeRabbit
New Features
Documentation