Clean up remaining TGFPNfl → ESPNNfl refactor vestiges #365
Labels
No labels
Kestra
bug
enhancement
someday
subtask
☁️ api
🎛️ infrastructure
🐞 sentry
📆 2025 Season
📝 pages
allpicks
📝 pages
picks
📝 pages
standings
🚀 performance
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
johnsturgeon/tgfp-web#365
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Context
Ahead of swapping the ESPN data source for TheSportsDB, the codebase should
have exactly one NFL-data concern in flight. An audit found that the earlier
TGFPNfl→ESPNNflrefactor is essentially complete — the module, all sixexported classes (
ESPNNfl,ESPNNflGame,ESPNNflTeam,ESPNNflOdd,ESPNNflStanding,ESPNSeasonType) and every import site are cleanlyESPN-named — but four vestiges remain.
The
tgfp-nflPyPI package itself was already removed fromconfig/requirements.txt(commitd32f1e4); the library is vendored atapp/espn_nfl/.Phase 1 — Zero-risk cleanup
No behavior change. Safe to do immediately and independently of the
TheSportsDB work.
1.1 Delete dead method
ESPNNflTeam.tgfp_id()File:
app/espn_nfl/espn_nfl.py, lines 418–430This method has zero callers. Verified across all file types repo-wide
(including Jinja templates), with no
getattranywhere that could hide adynamic call.
It is worth deleting beyond simply being dead code: line 427 is the only
place the NFL data-source module reaches into the database schema. It is a
leftover of the old "map data-source team → TGFP team" pattern. Removing it
leaves
app/espn_nfl/with no knowledge of the ORM models at all — which isprecisely the decoupling wanted before swapping providers.
1.2 Rename stale internal identifiers
app/espn_nfl/espn_nfl.pyfind_tgfp_nfl_standing_for_teamfind_standing_for_teamapp/espn_nfl/espn_nfl.pyESPNNflTeam"find_tgfp_nfl_standing_for_teamhas a single internal caller atapp/espn_nfl/espn_nfl.py:204and no external references, so the rename iscontained to one file.
Optional, judgment call:
app/espn_nfl/__init__.py:1has the module docstring"""TGFP NFL Model Objects""". This is ambiguous rather than wrong — TGFP isthe project name — so it may be left as is.
1.3 Fix stale documentation
File:
CLAUDE.mdapp/tgfp_nfl/tgfp_nfl.py; the actual path isapp/espn_nfl/espn_nfl.py.tgfp-nfl==6.3.3wraps API". The code isvendored in-repo and that dependency has been removed.
Phase 2 — Database column rename (decision required)
This phase is a separate decision and should not be bundled with Phase 1
without agreement.
Two live columns, confirmed present in the database:
game.tgfp_nfl_game_idteam.tgfp_nfl_team_idBoth carry the field description
"External TGFP/NFL game id", but they holdESPN ids today and would hold TheSportsDB ids after the swap. The name
is already inaccurate and the swap makes it more so.
Reference sites (7)
app/models/game.pyapp/models/team.pyapp/jobs/create_picks.pyapp/jobs/sync_team_records.pyapp/jobs/update_game.pyapp/espn_nfl/espn_nfl.pyProposed naming
Provider-neutral, so a future data-source change requires no further migration:
tgfp_nfl_game_id→external_game_idtgfp_nfl_team_id→external_team_idUpdate the
description=text on bothField(...)definitions to match.⚠️ Migration constraint
The existing Alembic revisions reference these column names as part of applied
migration history:
alembic/versions/9ff5e4af6bbc_01_initial_schema.py(lines 58, 76, 87, 128)alembic/versions/1885e311300d_02_added_field_uniqueness.py(lines 25–38)These files must not be edited. A repo-wide find-and-replace would corrupt
migration history. The rename requires a new migration:
Both columns are indexed and unique, so the generated migration should be
reviewed to confirm the indexes are renamed rather than dropped and recreated.
Timing
schema when the swap itself may not need to.
flight at once.
Acceptance criteria
ESPNNflTeam.tgfp_id()removedfind_tgfp_nfl_standing_for_teamrenamed, sole caller updatedespn_nfl.py:192)CLAUDE.mdlines 135 and 187 correctedall 6 remaining reference sites updated, indexes preserved
pylintstill reports 10.00/10/ping,/login, and the Discord OAuth flowVerification
After Phase 1, the only remaining matches should be the database column names
(and the Alembic history that must not be touched):
After Phase 2, that search should return only the two Alembic revision
files listed above.
Notes
tgfp.dump(repo root) contains the old column names. It is an untrackeddatabase dump artifact; no action needed.
login round trip.