fix: data fix for contradictory jersey state (#171) #197

Merged
forgejo_admin merged 1 commit from 171-fix-contradictory-jersey-state into main 2026-03-28 00:07:48 +00:00

Summary

  • Player id=161 ("Baby Betty") has contradictory jersey state: jersey_option=opt_out + jersey_order_status=pending in the players table, but a pending Reversible Jersey order (#14) in the orders table
  • Neither path completed payment; script resets both to clean state and checks sibling players under the same parent

Changes

  • scripts/fix_contradictory_jersey_state.py: Standalone data fix script with dry-run/commit modes. Resets player jersey fields to NULL/none, cancels pending orders, queries siblings under same parent for same contradictory state
  • tests/test_fix_contradictory_jersey_state.py: 10 tests covering detection logic, single-player fix, sibling inclusion, clean-sibling skip, missing-player error, and direct order cancellation

Test Plan

  • Tests pass locally (10/10 new tests pass)
  • Full suite: 605 passed, 1 pre-existing failure (unrelated admin dashboard URL test)
  • Run dry-run against prod: BASKETBALL_DATABASE_URL=<prod_url> python scripts/fix_contradictory_jersey_state.py
  • Run with --commit after verifying dry-run output

Review Checklist

  • Passed automated review-fix loop
  • No secrets committed
  • No unnecessary file changes
  • Commit messages are descriptive
  • Closes #171
  • forgejo_admin/basketball-api#170 -- parent bug (webhook sync gap)
  • project-westside-basketball -- the project this work belongs to
## Summary - Player id=161 ("Baby Betty") has contradictory jersey state: `jersey_option=opt_out` + `jersey_order_status=pending` in the players table, but a pending Reversible Jersey order (#14) in the orders table - Neither path completed payment; script resets both to clean state and checks sibling players under the same parent ## Changes - `scripts/fix_contradictory_jersey_state.py`: Standalone data fix script with dry-run/commit modes. Resets player jersey fields to NULL/none, cancels pending orders, queries siblings under same parent for same contradictory state - `tests/test_fix_contradictory_jersey_state.py`: 10 tests covering detection logic, single-player fix, sibling inclusion, clean-sibling skip, missing-player error, and direct order cancellation ## Test Plan - [x] Tests pass locally (10/10 new tests pass) - [x] Full suite: 605 passed, 1 pre-existing failure (unrelated admin dashboard URL test) - [ ] Run dry-run against prod: `BASKETBALL_DATABASE_URL=<prod_url> python scripts/fix_contradictory_jersey_state.py` - [ ] Run with `--commit` after verifying dry-run output ## Review Checklist - [x] Passed automated review-fix loop - [x] No secrets committed - [x] No unnecessary file changes - [x] Commit messages are descriptive ## Related Notes - Closes #171 - `forgejo_admin/basketball-api#170` -- parent bug (webhook sync gap) - `project-westside-basketball` -- the project this work belongs to
fix: add data fix script for contradictory jersey state (#171)
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
c9cd84d40b
Player id=161 has jersey_option=opt_out + jersey_order_status=pending
in the players table, but a pending Reversible Jersey order (#14) in
the orders table. Neither path completed payment. Script resets player
jersey fields to NULL/none and cancels pending orders. Also checks
sibling players under the same parent for the same contradictory state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

QA Review

Scope check: Script + tests only, no app code changes. Matches issue #171 acceptance criteria (player reset, order cancel, sibling check).

Script review (scripts/fix_contradictory_jersey_state.py):

  • Follows established backfill_stripe.py pattern: dry-run default, --commit flag, argparse CLI
  • Transaction safety: db.commit() / db.rollback() with finally: db.close()
  • Sibling query implemented per scope review comment -- all players under same parent_id checked
  • Fallback direct-cancel for target order #14 after sibling loop handles edge cases
  • Post-commit verification queries confirm fix took effect

Test review (tests/test_fix_contradictory_jersey_state.py):

  • 10 tests covering all branches: detection (4 cases), fix/skip (2 cases), run_fix (4 cases including sibling inclusion, sibling skip, not-found error, direct order cancel)
  • Uses unittest.mock.patch on constants for auto-generated IDs -- correct approach
  • Fixtures follow conftest.py patterns

Ruff: format and check both pass.
Full suite: 605 passed, 1 pre-existing failure (unrelated).

No issues found.

VERDICT: APPROVE

## QA Review **Scope check:** Script + tests only, no app code changes. Matches issue #171 acceptance criteria (player reset, order cancel, sibling check). **Script review (`scripts/fix_contradictory_jersey_state.py`):** - Follows established `backfill_stripe.py` pattern: dry-run default, `--commit` flag, argparse CLI - Transaction safety: `db.commit()` / `db.rollback()` with `finally: db.close()` - Sibling query implemented per scope review comment -- all players under same `parent_id` checked - Fallback direct-cancel for target order #14 after sibling loop handles edge cases - Post-commit verification queries confirm fix took effect **Test review (`tests/test_fix_contradictory_jersey_state.py`):** - 10 tests covering all branches: detection (4 cases), fix/skip (2 cases), run_fix (4 cases including sibling inclusion, sibling skip, not-found error, direct order cancel) - Uses `unittest.mock.patch` on constants for auto-generated IDs -- correct approach - Fixtures follow conftest.py patterns **Ruff:** format and check both pass. **Full suite:** 605 passed, 1 pre-existing failure (unrelated). No issues found. VERDICT: APPROVE
forgejo_admin deleted branch 171-fix-contradictory-jersey-state 2026-03-28 00:07:48 +00:00
Sign in to join this conversation.
No description provided.