Skip to content

feat: Add contest task pairs to seeds (#2734)#2735

Merged
KATO-Hiro merged 4 commits intostagingfrom
#2734
Oct 23, 2025
Merged

feat: Add contest task pairs to seeds (#2734)#2735
KATO-Hiro merged 4 commits intostagingfrom
#2734

Conversation

@KATO-Hiro
Copy link
Collaborator

@KATO-Hiro KATO-Hiro commented Oct 22, 2025

close #2734

Summary by CodeRabbit

  • New Features

    • Expanded problem library with new coding challenges in ABC and Math & Algorithm categories
    • Enhanced database initialization with improved concurrency handling
  • Documentation

    • Added internal documentation for database setup processes

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 22, 2025

Walkthrough

The 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

Cohort / File(s) Summary
Documentation
docs/dev-notes/2025-10-22/add-contest-task-pairs-to-seeds/plan.md
New plan document describing contest_task_pairs seeding implementation, including concurrency configuration, factory-based creation, idempotent checks, and execution flow.
Contest-Task Pair Data
prisma/contest_task_pairs.ts
New module exporting a constant array of contest_task_pairs objects with fields contest_id, problem_id, and problem_index.
Seed Implementation
prisma/seed.ts
Added defineContestTaskPairFactory import, QUEUE_CONCURRENCY.contestTaskPairs configuration, addContestTaskPairs() function for batch seeding with concurrency control and idempotent checks via findUnique, and addContestTaskPair() helper for individual record creation. Integrated into main seeding flow.
Task Data Expansion
prisma/tasks.ts
Added multiple new task entries including abc007\_3 under abc007 and nine new problems under math-and-algorithm contests (082, 050, 049, 044, 043, 041, 038, 031, 015).

Sequence Diagram

sequenceDiagram
    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
Loading

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

🐰 Hops through seeds with careful grace,
Contest pairs find their place,
Queues aligned, no tasks repeat—
Deduplication makes it neat!
From math to abc they grow,
A garden's perfect seed-time flow. 🌱

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning The pull request includes changes to prisma/tasks.ts that appear to be outside the scope of the linked issue requirement. Issue #2734 specifically requests adding the capability to seed contest-task pairs, which is implemented through the plan document, contest_task_pairs.ts data module, and seed.ts function updates. However, the additions to tasks.ts introduce new task entries (abc007_3, multiple math-and-algorithm problems) that go beyond implementing the seeding capability itself and constitute data population rather than infrastructure/capability changes. While these tasks may support the feature's functionality, they extend the scope beyond the core requirement. Consider separating the new task additions in tasks.ts into a separate pull request or confirm that these specific task additions were part of the original issue requirements. The core feature implementation (contest-task pair seeding capability) is complete and in-scope, but the new task data additions should be validated against the issue's original scope. If these tasks are necessary test data for this feature, document that intent clearly in the PR description or issue discussion.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: Add contest task pairs to seeds (#2734)" clearly and concisely describes the primary change in the changeset. The title accurately reflects the main objective: adding the capability to seed contest-task pair data. The changes include a plan document, a new contest_task_pairs data module, updates to seed.ts with seeding functions and factory implementation, and supporting task data additions. The title is specific, avoids vague language, and would be immediately understandable to teammates reviewing the commit history.
Linked Issues Check ✅ Passed The pull request successfully implements the requirements of issue #2734, which requests the ability to seed contest-task pair data in seed.ts. The implementation includes a new contest_task_pairs data module with the required data structure (contest_id, problem_id, problem_index), seeding functions in seed.ts with idempotent checks via findUnique, a factory pattern for creation (defineContestTaskPairFactory), proper concurrency handling, and integration into the main seeding flow. The plan document outlines the design approach, execution method (pnpm db:seed), and implementation patterns. All coding requirements specified in the linked issue have been addressed.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch #2734

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
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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5339224 and 8fce945.

📒 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 good

Entry structure is consistent and it’s referenced in contest_task_pairs. LGTM.


4718-4766: New math-and-algorithm entries added correctly

IDs, contest_id, and problem_index align with contest_task_pairs. LGTM.


4775-4788: math_and_algorithm_ac and _o added

Both 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 LGTM

Default and env override pattern matches existing knobs.


65-66: Seeding order updated

Placing addContestTaskPairs() after addTasks() is correct. LGTM.


221-231: Field mapping in create() looks correct

contestId, taskTableIndex, taskId match the data file. LGTM.

If you standardize data to task_id later, remember to update pair.problem_id usages here.

Copy link
Collaborator Author

@KATO-Hiro KATO-Hiro left a comment

Choose a reason for hiding this comment

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

LGTM

@KATO-Hiro KATO-Hiro merged commit 5fce5d8 into staging Oct 23, 2025
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #2734 branch October 23, 2025 12:05
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.

seed.ts に コンテストと問題を関連づけたデータを追加できるようにしましょう

1 participant

Comments