subWeeks(self::WEEKS)->toDateString(); $row = DB::table('forecast_outcomes') ->where('model_version', $modelVersion) ->where('forecast_for', '>=', $cutoff) ->selectRaw('COUNT(*) as total, SUM(CASE WHEN correct THEN 1 ELSE 0 END) as correct') ->first(); $total = (int) ($row->total ?? 0); if ($total < self::MIN_OUTCOMES) { return null; } return (int) ($row->correct ?? 0) / $total; } }