fix: replace row-by-row DELETE with bulk DELETE in career recalculation (#77) #92
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: cal/major-domo-database#92
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "issue/77-replace-row-by-row-delete-with-bulk-delete-in-care"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #77
Summary
Replaced N+1 row-by-row
DELETEloops with single bulkDELETEstatements 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 linesTest Results
No test suite for this repo. Changes verified by code review —
Model.delete().execute()is standard Peewee bulk delete, equivalent toDELETE FROM <table>with no WHERE clause.AI Code Review
Files Reviewed
app/db_engine.py(modified)Findings
Correctness
Model.delete().execute()is correct Peewee idiom forDELETE FROM <table>with no WHERE clause — matches the PR body's description exactly.BattingCareer,PitchingCareer, andFieldingCareer.BattingSeason.careeris aForeignKeyField(BattingCareer, null=True). If anyBattingSeasonrows hold a non-nullcareer_id, PostgreSQL's defaultRESTRICTbehavior 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.delete_instancehooks exist in this codebase, so bypassing the instance-level delete path has no side effects.Security
Style & Conventions
# Wipe existing dataretained — still accurate.Suggestions
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
Checkout
From your project repository, check out a new branch and test the changes.