paper-dynasty-database/app/services
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
..
__init__.py feat: formula engine for evolution value computation (WP-09) 2026-03-12 19:34:40 -05:00
apng_generator.py feat: APNG animated card effects for T3/T4 refractor tiers (#186) 2026-04-07 03:22:05 +00:00
card_storage.py fix: address review feedback (#187) 2026-04-06 20:03:02 -05:00
formula_engine.py refactor: rename evolution system to refractor 2026-03-23 13:31:55 -05:00
refractor_boost.py fix: address PR #177 review — move import os to top-level, add audit idempotency guard 2026-03-30 13:16:27 -05:00
refractor_evaluator.py feat: Refractor Phase 2 integration — wire boost into evaluate-game 2026-03-30 13:04:52 -05:00
refractor_init.py fix: complete remaining evolution→refractor renames from review 2026-03-23 14:17:03 -05:00
refractor_service.py refactor: extract evaluate-game business logic from router to service layer (#202) 2026-04-08 00:37:26 -05:00
season_stats.py fix: add pitcher_id null guard in _get_player_pairs 2026-03-23 12:50:16 -05:00