Skip to content

repositoryのUpsertGameCreatorPresetJobsRelations実装#1622

Open
ikura-hamu wants to merge 5 commits into
mainfrom
feat/repository_upsert_game_creator_job_relations
Open

repositoryのUpsertGameCreatorPresetJobsRelations実装#1622
ikura-hamu wants to merge 5 commits into
mainfrom
feat/repository_upsert_game_creator_job_relations

Conversation

@ikura-hamu

@ikura-hamu ikura-hamu commented Jun 19, 2026

Copy link
Copy Markdown
Member

fix #1526

  • ✅ TestUpsertGameCreatorPresetJobsRelationsの仮実装
  • ✨ UpsertGameCreatorPresetJobsRelationsの実装
  • ✅ TestUpsertGameCreatorPresetJobsRelationsのテストケース実装
  • 📝 interface にコメント追加

Summary by CodeRabbit

  • New Features

    • Implemented batch association functionality for linking game creators with preset jobs
    • Enhanced error handling to prevent invalid associations with non-existent creators or jobs
  • Tests

    • Added comprehensive test coverage validating creator-job association behavior including edge cases and error scenarios

@ikura-hamu ikura-hamu requested a review from a team as a code owner June 19, 2026 12:44
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cc98c4e7-3c2a-4dad-a41b-40cbd04b69a3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Implements the previously stubbed UpsertGameCreatorPresetJobsRelations method in the GORM repository layer. The method builds join-table rows from a creator-to-jobs map, performs a batch upsert via GORM's OnConflict clause, and maps MySQL error 1452 to repository.ErrForeignKeyViolated. A doc comment and a new table-driven test are added.

Changes

UpsertGameCreatorPresetJobsRelations Implementation

Layer / File(s) Summary
Interface doc + GORM implementation
src/repository/game_creator.go, src/repository/gorm2/game_creator.go
Adds a doc comment on the interface stating ErrForeignKeyViolated is returned for non-existent IDs. Imports gorm.io/gorm/clause and replaces the stub with a working implementation: builds gameCreatorJobRelation rows from the input map, returns early on empty input, upserts via Table(...).Clauses(OnConflict{DoUpdates: game_creator_id}).Create(...), and maps MySQL 1452 to repository.ErrForeignKeyViolated.
Table-driven tests
src/repository/gorm2/game_creator_test.go
Adds TestUpsertGameCreatorPresetJobsRelations covering: no-op on empty map, adding preset jobs for one and multiple creators, and ErrForeignKeyViolated for missing jobs or creators. Verifies results by preloading, sorting with slices.SortFunc, and asserting IDs and timestamps.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Review effort 3/5

Suggested reviewers

  • mathsuky

Poem

🐇 Hop, hop, the stub is gone at last,
Upsert rows inserted lightning-fast!
Foreign keys caught with error care,
Join-table rows bloom everywhere.
This bunny cheers: the TODO's past! 🎉

🚥 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 The PR title accurately describes the main change: implementing the UpsertGameCreatorPresetJobsRelations repository method.
Linked Issues check ✅ Passed The implementation fully addresses issue #1526 by implementing the UpsertGameCreatorPresetJobsRelations method with proper upsert logic for creator-job relations.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing UpsertGameCreatorPresetJobsRelations: interface documentation, method implementation, and comprehensive test coverage.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/repository_upsert_game_creator_job_relations

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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/repository/gorm2/game_creator_test.go`:
- Around line 821-823: The cleanup deletion at the Delete() call for GameTable2
is using afterCreatorPresetJobsRelations (which appears to be a slice of
GameCreatorTable) instead of explicit game IDs, causing incorrect or overly
broad deletion. Modify the Delete() call to pass explicit game IDs extracted
from testCase instead of the afterCreatorPresetJobsRelations slice to ensure
only the intended GameTable2 rows are deleted.
- Around line 838-843: The Find query in the test fetches all creators from the
database table without filtering, which causes flaky tests when unrelated test
data exists. Add a WHERE clause to filter the database query by the creator IDs
that are expected in testCase.afterCreatorPresetJobsRelations before calling
Find on the result variable, ensuring that the length assertion and the loop
iterating over result only validate the current test's creators.
🪄 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: CHILL

Plan: Pro

Run ID: f4d1ad99-6a42-4811-ab95-e5e55a9d51cf

📥 Commits

Reviewing files that changed from the base of the PR and between c8888ab and 740965f.

📒 Files selected for processing (3)
  • src/repository/game_creator.go
  • src/repository/gorm2/game_creator.go
  • src/repository/gorm2/game_creator_test.go

Comment thread src/repository/gorm2/game_creator_test.go
Comment thread src/repository/gorm2/game_creator_test.go
@github-actions

Copy link
Copy Markdown

Migrate lint ✅

Lint output

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.59%. Comparing base (c8888ab) to head (f7d2daa).

Files with missing lines Patch % Lines
src/repository/gorm2/game_creator.go 80.00% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1622      +/-   ##
==========================================
+ Coverage   51.50%   51.59%   +0.08%     
==========================================
  Files         147      147              
  Lines       11173    11201      +28     
==========================================
+ Hits         5755     5779      +24     
- Misses       5079     5080       +1     
- Partials      339      342       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

repositoryの UpsertGameCreatorPresetJobsRelations の実装

1 participant