paper-dynasty-database/app
Cal Corum e8b1091d8a refactor: extract evaluate-game business logic from router to service layer (#202)
Closes #202

Adds app/services/refractor_service.py with two service functions:

- ensure_variant_cards: idempotent function that creates missing variant
  cards for all tiers up to a target, with partial failure handling and
  REFRACTOR_BOOST_ENABLED kill switch support.

- evaluate_and_boost: combines evaluate_card(dry_run=True) with
  ensure_variant_cards so both tier computation and variant-card creation
  happen in one testable call without HTTP round-trips.

Updates both router endpoints to use evaluate_and_boost:

- POST /cards/{card_id}/evaluate now calls evaluate_and_boost instead of
  evaluate_card directly, which also fixes the broken variant creation on
  the manual evaluate path (variant cards are now created when a tier-up
  is detected, not just recorded).

- POST /evaluate-game/{game_id} replaces ~55 lines of inline boost
  orchestration (boost_enabled flag, tier loop, partial failure tracking,
  card_type/track null checks) with a single evaluate_and_boost call.
  Response shape is unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 00:37:26 -05:00
..
models refactor: split PlayerSeasonStats into BattingSeasonStats and PitchingSeasonStats 2026-03-17 09:43:22 -05:00
routers_v2 refactor: extract evaluate-game business logic from router to service layer (#202) 2026-04-08 00:37:26 -05:00
seed refactor: rename evolution system to refractor 2026-03-23 13:31:55 -05:00
services refactor: extract evaluate-game business logic from router to service layer (#202) 2026-04-08 00:37:26 -05:00
__init__.py Initial Commit with /current 2023-09-13 14:44:26 -05:00
card_creation.py Update card_creation.py 2024-02-24 21:36:44 -06:00
db_engine.py chore: remove unused RefractorTierBoost and RefractorCosmetic tables 2026-04-05 22:27:26 -05:00
db_helpers.py Fix PostgreSQL upsert column names and CSV null handling 2026-01-30 17:28:40 -06:00
dependencies.py fix: use constant-time comparison for bearer token validation (#8) 2026-03-05 03:43:59 +00:00
main.py refactor: rename evolution system to refractor 2026-03-23 13:31:55 -05:00
player_scouting.py Update player_scouting.py 2023-09-24 19:00:21 -05:00