Skip to content

feat(contest): extend AOJ_JAG for summer, winter spring #3592

Merged
KATO-Hiro merged 4 commits into
stagingfrom
#3580
May 28, 2026
Merged

feat(contest): extend AOJ_JAG for summer, winter spring #3592
KATO-Hiro merged 4 commits into
stagingfrom
#3580

Conversation

@KATO-Hiro
Copy link
Copy Markdown
Collaborator

@KATO-Hiro KATO-Hiro commented May 27, 2026

close #3580

Summary by CodeRabbit

  • 改善
    • AOJ の JAG コンテスト判定と表示ロジックを拡張しました。夏合宿・冬合宿・春合宿や「-dayN…」付きの形式を正しく認識・分類し、表示名変換も対応しました。
  • テスト
    • JAG 形式に関する自動テスト群を拡張・整理し、4桁年やデイ表記など各種表記の判定・表示期待値を追加検証するようにしました。

KATO-Hiro and others added 2 commits May 27, 2026 13:58
Add Summer/Winter/Spring camp contest types to JAG_TRANSLATIONS and
update the regex from `\d*$` to `\d*(-day\d+[A-Z]?)?$` so that
contest IDs like JAGSummer2006-day2 and JAGSummer2012-day3A are
correctly classified.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6f1b5aed-39df-4510-9bbe-2466da490290

📥 Commits

Reviewing files that changed from the base of the PR and between f5cc636 and 1a54085.

📒 Files selected for processing (2)
  • src/lib/utils/contest.ts
  • src/test/lib/utils/contest.test.ts

📝 Walkthrough

Walkthrough

JAG 合宿形式の contest_id(例: JAGSummer2024-day1A)を AOJ_JAG と判定できるよう正規表現を導入し、ラベル変換ルールと対応テストデータ・テストを追加・更新しました。

Changes

JAG camp contest support

Layer / File(s) Summary
実装: regex と判定/ラベルの統一
src/lib/utils/contest.ts
JAG 判定を regexForJag(YYYY4桁+任意の -day\d+[A-Z]?)へ置換し、classifyContest / getContestNameLabel / isAojContest を共通判定へ切替。JAG_TRANSLATIONSSummer/Winter/Spring-day の変換を追加。
テストデータ生成の拡張
src/test/lib/utils/test_cases/contest_name_and_task_index.ts
AOJ_JAG_CAMP_TEST_DATAgenerateAojJagCampTestCases を導入し、aojJag が合宿・day 付きケースを含むように拡張。
テストケース追加 (labels / types)
src/test/lib/utils/test_cases/contest_name_labels.ts, src/test/lib/utils/test_cases/contest_type.ts
aojJag のテストケース群を追加し、Spring/Winter/Summer と day 区分を含む多数の contestId を網羅。
テストのワイヤリングと追加検証
src/test/lib/utils/contest.test.ts
describe 表題を「means AOJ JAG」に統一し、4桁年を欠く JAG-like に対して classifyContestnull を返す、getContestNameLabel / addContestNameToTaskIndex が AOJ 形式を生成しない、などの test.each を追加。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

春・夏・冬の JAG が集い来る、
day に A も B も踊る、
正規表現で見分けて、
ラベルは静かに咲く。 🏕️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Pull request title accurately describes the main change: extending AOJ_JAG support for summer, winter, and spring camps.
Linked Issues check ✅ Passed Pull request fulfills all linked issue #3580 objectives: JAG summer, spring, and winter camp imports are now supported with proper validation.
Out of Scope Changes check ✅ Passed All changes are directly related to extending AOJ_JAG detection logic and handling new camp contest formats, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch #3580

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.

@KATO-Hiro KATO-Hiro changed the title feat(contest): extend AOJ_JAG regex to match -dayN/-dayNA suffixes feat(contest): extend AOJ_JAG for summer, winter spring May 27, 2026
Copy link
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/utils/contest.ts`:
- Line 104: The regex that detects JAG contest IDs wrongly allows missing year
because it uses \d*; update the pattern used where contest_id is tested (the
line with
/^JAG(Prelim|Regional|Summer|Winter|Spring)\d*(-day\d+[A-Z]?)?$/.exec(contest_id))
to require one or more digits for the year (change \d* to \d+ or a more specific
quantifier like \d{4}), so IDs like "JAGSummer-day2" no longer match.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f07c2a10-35fc-4f62-a0cd-f58a286305aa

📥 Commits

Reviewing files that changed from the base of the PR and between 6cd8aba and d29ebb3.

📒 Files selected for processing (6)
  • prisma/tasks.ts
  • src/lib/utils/contest.ts
  • src/test/lib/utils/contest.test.ts
  • src/test/lib/utils/test_cases/contest_name_and_task_index.ts
  • src/test/lib/utils/test_cases/contest_name_labels.ts
  • src/test/lib/utils/test_cases/contest_type.ts

Comment thread src/lib/utils/contest.ts Outdated
Change `\d*` to `\d{4}` so that bare contest IDs without a year
(e.g. JAGPrelim, JAGSummer-day2) no longer match AOJ_JAG.
Add negative test cases to cover the boundary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/utils/contest.ts`:
- Line 104: The JAG detection is inconsistent: classifyContest uses the strict
regex /^JAG(Prelim|Regional|Summer|Winter|Spring)\d{4}(-day\d+[A-Z]?)?$/ but
getContestNameLabel and isAojContest still use startsWith('JAG'), causing
mismatches (e.g., "JAGSummer-day2"). Update getContestNameLabel and isAojContest
to use the same regex-based check (or extract a shared isJagContest helper that
tests the strict regex) instead of startsWith so all three functions use the
same validation logic.

In `@src/test/lib/utils/contest.test.ts`:
- Around line 216-223: Add negative test cases for the same year-less JAG-like
inputs so the behavior is consistent across related functions: for each of
['JAGSummer-day2','JAGPrelim','JAGRegional'] assert that
classifyContest(contestId) is null AND that getContestNameLabel(contestId) does
not return a JAG-style label (e.g., returns null/undefined or a non-JAG string
per existing contract) and that addContestNameToTaskIndex does not add a JAG
entry for the same contestId; update the describe block to include tests calling
getContestNameLabel and addContestNameToTaskIndex (or inspect the index result)
to confirm they do not treat year-less inputs as JAG.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 10c11156-ef92-4e09-bff4-f0da71f9db4a

📥 Commits

Reviewing files that changed from the base of the PR and between d29ebb3 and f5cc636.

📒 Files selected for processing (2)
  • src/lib/utils/contest.ts
  • src/test/lib/utils/contest.test.ts

Comment thread src/lib/utils/contest.ts Outdated
Comment thread src/test/lib/utils/contest.test.ts
Extract the JAG regex into a named constant `regexForJag` and replace
loose `startsWith('JAG')` guards in getContestNameLabel and isAojContest
so that malformed IDs (no 4-digit year) are no longer treated as JAG.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
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 db6f8fe into staging May 28, 2026
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #3580 branch May 28, 2026 09:54
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] JAG 春・夏・冬合宿をインポートできるようにしましょう

1 participant