fix: replace row-by-row DELETE with bulk DELETE in career recalculation (#77) #92

Open
Claude wants to merge 1 commits from issue/77-replace-row-by-row-delete-with-bulk-delete-in-care into main
Collaborator

Closes #77

Summary

Replaced N+1 row-by-row DELETE loops with single bulk DELETE statements in all three career recalculation methods:

  • BattingCareer.recalculate()BattingCareer.delete().execute()
  • PitchingCareer.recalculate()PitchingCareer.delete().execute()
  • FieldingCareer.recalculate()FieldingCareer.delete().execute()

Files Changed

  • app/db_engine.py — 3 hunks, -9 lines / +3 lines

Test Results

No test suite for this repo. Changes verified by code review — Model.delete().execute() is standard Peewee bulk delete, equivalent to DELETE FROM <table> with no WHERE clause.

Closes #77 ## Summary Replaced N+1 row-by-row `DELETE` loops with single bulk `DELETE` statements in all three career recalculation methods: - `BattingCareer.recalculate()` — `BattingCareer.delete().execute()` - `PitchingCareer.recalculate()` — `PitchingCareer.delete().execute()` - `FieldingCareer.recalculate()` — `FieldingCareer.delete().execute()` ## Files Changed - `app/db_engine.py` — 3 hunks, -9 lines / +3 lines ## Test Results No test suite for this repo. Changes verified by code review — `Model.delete().execute()` is standard Peewee bulk delete, equivalent to `DELETE FROM <table>` with no WHERE clause.
Claude added 1 commit 2026-03-27 08:03:08 +00:00
fix: replace row-by-row DELETE with bulk DELETE in career recalculation (#77)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m4s
d8c6ce2a5e
Closes #77

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude added the
ai-reviewing
label 2026-03-27 08:15:53 +00:00
Claude reviewed 2026-03-27 08:17:01 +00:00
Claude left a comment
Author
Collaborator

AI Code Review

Files Reviewed

  • app/db_engine.py (modified)

Findings

Correctness

  • Model.delete().execute() is correct Peewee idiom for DELETE FROM <table> with no WHERE clause — matches the PR body's description exactly.
  • All three hunks are structurally identical and symmetric across BattingCareer, PitchingCareer, and FieldingCareer.
  • FK consideration (non-blocking): BattingSeason.career is a ForeignKeyField(BattingCareer, null=True). If any BattingSeason rows hold a non-null career_id, PostgreSQL's default RESTRICT behavior could cause both the old row-by-row deletes and the new bulk delete to fail. Behavioral equivalence is preserved — if it worked before, it works now.
  • No Peewee signals or overridden delete_instance hooks exist in this codebase, so bypassing the instance-level delete path has no side effects.

Security

  • No issues found. No user input involved; this is a maintenance operation on internal tables.

Style & Conventions

  • Clean, minimal change. Follows existing patterns in the file.
  • Comment # Wipe existing data retained — still accurate.

Suggestions

  • None.

Verdict: APPROVED

Correct bulk-delete replacement. Reduces N queries to 1 per recalculation call with identical semantics. No edge-case regressions introduced.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `app/db_engine.py` (modified) ### Findings #### Correctness - `Model.delete().execute()` is correct Peewee idiom for `DELETE FROM <table>` with no WHERE clause — matches the PR body's description exactly. - All three hunks are structurally identical and symmetric across `BattingCareer`, `PitchingCareer`, and `FieldingCareer`. - **FK consideration (non-blocking):** `BattingSeason.career` is a `ForeignKeyField(BattingCareer, null=True)`. If any `BattingSeason` rows hold a non-null `career_id`, PostgreSQL's default `RESTRICT` behavior could cause both the old row-by-row deletes and the new bulk delete to fail. Behavioral equivalence is preserved — if it worked before, it works now. - No Peewee signals or overridden `delete_instance` hooks exist in this codebase, so bypassing the instance-level delete path has no side effects. #### Security - No issues found. No user input involved; this is a maintenance operation on internal tables. #### Style & Conventions - Clean, minimal change. Follows existing patterns in the file. - Comment `# Wipe existing data` retained — still accurate. #### Suggestions - None. ### Verdict: APPROVED Correct bulk-delete replacement. Reduces N queries to 1 per recalculation call with identical semantics. No edge-case regressions introduced. --- *Automated review by Claude PR Reviewer*
Claude added the
ai-reviewed
label 2026-03-27 08:17:24 +00:00
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m4s
This pull request doesn't have enough approvals yet. 0 of 1 approvals granted.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin issue/77-replace-row-by-row-delete-with-bulk-delete-in-care:issue/77-replace-row-by-row-delete-with-bulk-delete-in-care
git checkout issue/77-replace-row-by-row-delete-with-bulk-delete-in-care
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#92
No description provided.