Skip to content

feat: Add math and algo book to contest table (#2785)#2786

Merged
KATO-Hiro merged 6 commits intostagingfrom
#2785
Nov 3, 2025
Merged

feat: Add math and algo book to contest table (#2785)#2786
KATO-Hiro merged 6 commits intostagingfrom
#2785

Conversation

@KATO-Hiro
Copy link
Collaborator

@KATO-Hiro KATO-Hiro commented Nov 3, 2025

close #2785

See #662

Summary by CodeRabbit

  • New Features

    • Added a Math & Algorithm contest group with custom display behavior and provider support.
    • Expanded problem catalog with 20+ new contest tasks from ABC, ARC, Typical90, Panasonic, JSC, DP, and others.
  • Documentation

    • Added a step-by-step guide for importing contest-task CSV data into the database, including preparation, import steps, troubleshooting, and lessons learned.
  • Tests

    • Added unit tests and mock data covering the Math & Algorithm provider (filtering, metadata, table generation, sorting, and edge cases).

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 3, 2025

Walkthrough

Adds import documentation for bringing contest-task pairs into Supabase, extends Prisma data with many new tasks and contest-task entries for "math-and-algorithm", introduces MathAndAlgorithmProvider (UI provider) and corresponding tests/mocks.

Changes

Cohort / File(s) Change Summary
Documentation
docs/dev-notes/2025-11-03/import-contest-task-pair-to-supabase/plan.md, docs/dev-notes/2025-11-03/add_tests_for_contest_table_provider/plan.md
New guides: CSV-to-Supabase import plan with CSV schema, Python UUID/timestamp script, import steps, troubleshooting, and lessons; test plan for MathAndAlgorithmProvider with 11 unit tests and mock data guidance.
Prisma — Contest-Task Pairs
prisma/contest_task_pairs.ts
Appended ~29 new entries to the exported contest_task_pairs array, all with contest_id: 'math-and-algorithm' mapping various problem_id and problem_index values.
Prisma — Tasks
prisma/tasks.ts
Added ~20+ new task objects (ids, contest_id, problem_index, name, title) across abc, arc, typical90, panasonic2020, jsc, dp, and related contests; purely data additions.
UI — Contest Table Provider
src/lib/utils/contest_table_provider.ts
Added MathAndAlgorithmProvider extending ContestTableProviderBase; implements filtering, metadata, and display config (no headers/round labels); registered in contestTableProviderGroups and presets.
Tests / Mocks
src/test/lib/utils/contest_table_provider.test.ts, src/test/lib/utils/test_cases/contest_table_provider.ts
Tests updated/added to exercise MathAndAlgorithmProvider; new mock dataset taskResultsForMathAndAlgorithmProvider with ~10 mock task results; provider integrated into test suite and name-label mocks updated.
Other
package.json (manifest reference)
Manifest referenced in summaries; no code changes indicated.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Script as Python CSV Script
  participant Supa as Supabase CSV Import
  participant DB as Prisma DB (schema)
  participant App as Application (startup)
  participant Provider as MathAndAlgorithmProvider

  rect rgb(240,248,255)
    Dev->>Script: prepare CSV (add id, createdAt, updatedAt)
    Script->>Dev: produce tessoku-book-with-id.csv
    Dev->>Supa: upload CSV, map columns -> table
    Supa-->>DB: imported rows available
  end

  rect rgb(245,255,240)
    App->>DB: read tasks/contest_task_pairs
    App->>Provider: register provider via contestTableProviderGroups
    Provider->>App: expose metadata/filter/display rules
    App->>Provider: request table for task results
    Provider-->>App: filtered/structured contest table
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas needing attention:
    • Verify consistency of newly added prisma/tasks.ts entries (ids, contest_id, problem_index).
    • Confirm no duplicate task entries (note earlier mention of a potential duplicate such as dp_d).
    • Ensure contest_task_pairs mappings align with task ids and indices.
    • Review provider registration to avoid naming/registration conflicts with existing presets.

Poem

🐰 I hopped through CSV rows one night,
I stamped each id and set timestamps right,
Into Supabase the problems flew,
A Math-and-Algorithm garden grew,
My whiskers twitch — new tasks in sight! ✨

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat: Add math and algo book to contest table' clearly summarizes the main change in the changeset. The pull request introduces a new contest category called 'MathAndAlgorithm' to the contest table system, adds associated task data, and includes comprehensive tests for the new provider. The title accurately reflects this primary objective without being vague or misleading.
Linked Issues check ✅ Passed The linked issue #2785 requests enabling import of 'Math and Algorithm' book problems into the system. The PR delivers on this objective by: (1) introducing a new MathAndAlgorithmProvider class that extends ContestTableProviderBase with appropriate filtering and display configuration; (2) adding numerous task entries to prisma/tasks.ts for math-and-algorithm contest problems; (3) creating corresponding contest-task pair entries in prisma/contest_task_pairs.ts; (4) implementing comprehensive test coverage for the new provider; and (5) providing documentation for the data import workflow. All coding requirements to support the new contest type are satisfied.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to implementing support for the 'Math and Algorithm' book contest type. The modifications include: provider implementation, task and contest-task-pair data additions, test infrastructure, test cases and mocks, and supporting documentation. No unrelated changes such as refactoring, bug fixes for other features, or cosmetic improvements to unrelated code are present. All additions follow the established patterns in the codebase (mirroring TessokuBookProvider).
✨ 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 #2785

📜 Recent 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 dc10ec5 and 3685fb1.

📒 Files selected for processing (4)
  • docs/dev-notes/2025-11-03/add_tests_for_contest_table_provider/plan.md (1 hunks)
  • prisma/tasks.ts (13 hunks)
  • src/test/lib/utils/contest_table_provider.test.ts (3 hunks)
  • src/test/lib/utils/test_cases/contest_table_provider.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/dev-notes/2025-11-03/add_tests_for_contest_table_provider/plan.md
⏰ 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 (4)
src/test/lib/utils/test_cases/contest_table_provider.ts (1)

301-340: LGTM! Math and Algorithm test data follows established patterns.

The test data structure mirrors the TessokuBookProvider pattern appropriately, with consistent formatting and proper coverage of the 001-104 range (boundary testing with 028 and 102).

src/test/lib/utils/contest_table_provider.test.ts (2)

15-15: LGTM! Proper mock integration.

The MathAndAlgorithmProvider import and mock classification are correctly integrated following the established pattern.

Also applies to: 36-37


558-707: LGTM! Comprehensive test suite for MathAndAlgorithmProvider.

Excellent test coverage with 11 tests covering filtering, metadata, display configuration, table generation, sorting, boundary conditions, and edge cases. The implementation correctly mirrors the TessokuBookProvider pattern.

prisma/tasks.ts (1)

3873-5605: LGTM! New task entries are well-structured and duplicate-free.

All 21 new task entries follow the consistent structure and no duplicates were detected. The arc084_b entry with contest_id: 'abc077' is correct, as these contests share problems per AtCoder's practice.


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: 1

📜 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 1eb8d9b and dc10ec5.

📒 Files selected for processing (4)
  • docs/dev-notes/2025-11-03/import-contest-task-pair-to-supabase/plan.md (1 hunks)
  • prisma/contest_task_pairs.ts (1 hunks)
  • prisma/tasks.ts (14 hunks)
  • src/lib/utils/contest_table_provider.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 (5)
docs/dev-notes/2025-11-03/import-contest-task-pair-to-supabase/plan.md (1)

1-115: Documentation looks comprehensive.

The documentation provides a clear workflow for importing CSV data into Supabase, including troubleshooting guidance and lessons learned. This will be helpful for future imports.

prisma/tasks.ts (1)

3873-3879: New task entries look good.

All the new task entries follow the correct format and are properly structured. They align with the math-and-algorithm contest additions in the contest_task_pairs file.

Also applies to: 3911-3917, 3942-3948, 3957-3963, 3980-3986, 3987-3993, 4026-4032, 4041-4047, 4056-4062, 4071-4077, 4093-4099, 4100-4106, 4107-4113, 5397-5403, 5404-5410, 5411-5417, 5425-5431, 5584-5590, 5591-5597, 5606-5612

prisma/contest_task_pairs.ts (1)

67-201: New contest-task pairs are properly structured.

All the new entries for the math-and-algorithm contest follow the correct format, and all referenced problem_id values exist in the tasks file. The data relationships are consistent.

src/lib/utils/contest_table_provider.ts (2)

271-298: MathAndAlgorithmProvider implementation is solid.

The new provider class properly extends ContestTableProviderBase and follows the established pattern used by TessokuBookProvider. All required methods are implemented correctly, and the display configuration is appropriate for a single-group contest type.


554-564: Provider registration follows best practices.

The new provider is properly registered in the presets and added to the global contestTableProviderGroups object, maintaining consistency with existing provider registrations.

Also applies to: 592-592

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 3b5bc58 into staging Nov 3, 2025
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #2785 branch November 3, 2025 12:10
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.

[Feat] 数学・アルゴ本の問題をインポートできるようにしましょう

1 participant