deal with suspended matches

This commit is contained in:
silva guimaraes 2025-06-28 19:00:18 -03:00
parent 8af5cb0d33
commit 6e35f8eae9

View file

@ -70,6 +70,7 @@ type time = { start_timestamp : int; half : half } [@@deriving show]
type status =
| NotStarted of { start_timestamp : int }
| Suspended of { start_timestamp : int }
| Postponed
| Canceled
| InProgress of time
@ -107,7 +108,7 @@ module Tournament = struct
|> List.filter (fun x ->
match x.status with
| Postponed | Completed _ | Canceled -> false
| InProgress _ | NotStarted _ -> true)
| Suspended _ | InProgress _ | NotStarted _ -> true)
|> List.filter (fun x ->
if tournament.context.filter_foreigners then
is_conmebol x.home_team || is_conmebol x.away_team
@ -116,6 +117,7 @@ module Tournament = struct
let ts =
match x.status with
| Postponed | Canceled -> -1
| Suspended t -> t.start_timestamp
| NotStarted t -> t.start_timestamp
| InProgress t -> t.start_timestamp
| Completed t -> t.start_timestamp
@ -128,6 +130,7 @@ module Tournament = struct
| Postponed | Completed _ | Canceled ->
failwith "impossible: improper filter"
| InProgress _ -> "NOW! "
| Suspended _ -> "SUS! "
| NotStarted t -> (
let ts1 =
t.start_timestamp |> float_of_int |> Unix.localtime
@ -203,10 +206,10 @@ let matches_of_api_events (e : api_events) =
in
let t = { start_timestamp = m.startTimestamp; half = h } in
match typ with
| "notstarted" ->
NotStarted { start_timestamp = m.startTimestamp }
| "notstarted" -> NotStarted { start_timestamp = m.startTimestamp }
| "postponed" -> Postponed
| "canceled" -> Canceled
| "suspended" -> Suspended { start_timestamp = m.startTimestamp }
| "inprogress" -> InProgress t
| "finished" -> Completed t
| _ -> failwith (sprintf "unrecognized match type: %s" typ));