WAGERBABE DOCS
All Stories
3-2-game-status-classifierDoneEpic 3.2

Story 3.2: Game Status Classifier

Status: done

Tasks

  • Task 1: Service Layer Classification (AC: 1, 2) **ADAPTED - No local games table**
    • 1.1 Created `ComputedStatus` enum with values: live, upcoming, scheduled, completed
    • 1.2 Implemented `GameStatusClassifier.classify()` static method with time-based classification
    • 1.3 Defined `CACHE_TTL_BY_STATUS` mapping for tiered caching
    • 1.4 Handles timezone-aware and naive datetimes correctly
  • Task 2: Classification Logic (AC: 2, 3) **ADAPTED - Service layer instead of DB trigger**
    • 2.1 Classification respects explicit API status (completed, final, live, in_progress)
    • 2.2 Time-based thresholds: live (0-4hr), upcoming (<2hr), scheduled (>2hr), completed (>4hr)
    • 2.3 Integrated into `CardsService._transform_to_cards()` for runtime classification
    • 2.4 Case-insensitive status comparison for API consistency
  • Task 3: Background Reclassification Job (AC: 4)
    • 3.1 Added `reclassify_game_statuses()` method to `GameMonitoringScheduler`
    • 3.2 Queries `game_results` table for games needing reclassification
    • 3.3 Registered in scheduler with 1-minute interval
    • 3.4 Error handling with per-game exception isolation
  • Task 4: Status Transition Logging (AC: 6)
    • 4.1 Created `StatusTransition` Pydantic model for audit records
    • 4.2 Implemented `classify_and_cache()` to track transitions in Redis
    • 4.3 7-day retention policy for Redis-stored transitions (max 50 per game)
    • 4.4 In-memory transition log for recent transitions
  • Task 5: API Integration (AC: 7)
    • 5.1 Updated `GameCard` Pydantic model with `computed_status` field
    • 5.2 CardsService automatically computes status during transformation
    • 5.3 Added `/health/classifier` endpoint for monitoring
    • 5.4 `get_classifier_health()` function exposes configuration and metrics
  • Task 6: Testing & Validation (AC: 1-7)
    • 6.1 Unit tests: 49 tests covering all classification scenarios (PASSED)
    • 6.2 Tests for time-based classification with boundary conditions
    • 6.3 Tests for explicit status override (completed, live, etc.)
    • 6.4 Tests for timezone handling (naive and aware datetimes)
    • 6.5 Tests for cache TTL mapping and cache strategy methods
    • 6.6 Tests for async methods with mocked Redis

Progress

Tasks6/6
Acceptance Criteria0
Total Tasks6