From f613203cbea07671f7d28cda0d43cf21ea1b6624 Mon Sep 17 00:00:00 2001 From: silva guimaraes Date: Sat, 26 Jul 2025 20:19:28 -0300 Subject: [PATCH] bugfix --- lib/lib.ml | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/lib/lib.ml b/lib/lib.ml index 33bf2b2..fa1ea02 100644 --- a/lib/lib.ml +++ b/lib/lib.ml @@ -309,6 +309,21 @@ let tables_of_api_standings_total (s : api_standings_total) : table list = let matches_of_api_events (e : api_events) = e.events |> List.map (fun (m : api_match) -> + let period_start_timestamp = + match m.time with + | { + currentPeriodStartTimestamp = Some x; + injuryTime1 = _; + injuryTime2 = _; + } -> + x + | { + currentPeriodStartTimestamp = None; + injuryTime1 = _; + injuryTime2 = _; + } -> + m.startTimestamp + in { home_team = m.homeTeam; away_team = m.awayTeam; @@ -336,14 +351,13 @@ let matches_of_api_events (e : api_events) = { injuryTime1 = x; injuryTime2 = None; - currentPeriodStartTimestamp = Some z; + currentPeriodStartTimestamp = _; } ) -> InProgress { start_timestamp = m.startTimestamp; half = - First_Half - { injury_time1 = x; period_start_timestamp = z }; + First_Half { injury_time1 = x; period_start_timestamp }; score = { home_score = m.homeScore.current; @@ -355,7 +369,7 @@ let matches_of_api_events (e : api_events) = { injuryTime1 = x; injuryTime2 = y; - currentPeriodStartTimestamp = Some z; + currentPeriodStartTimestamp = _; } ) -> InProgress { @@ -365,7 +379,7 @@ let matches_of_api_events (e : api_events) = { injury_time1 = x; injury_time2 = y; - period_start_timestamp = z; + period_start_timestamp; }; score = { @@ -378,7 +392,7 @@ let matches_of_api_events (e : api_events) = { injuryTime1 = x; injuryTime2 = y; - currentPeriodStartTimestamp = Some z; + currentPeriodStartTimestamp = _; } ) -> InProgress { @@ -388,7 +402,7 @@ let matches_of_api_events (e : api_events) = { injury_time1 = x; injury_time2 = y; - period_start_timestamp = z; + period_start_timestamp; }; score = { @@ -420,7 +434,7 @@ let matches_of_api_events (e : api_events) = { injuryTime1 = x; injuryTime2 = y; - currentPeriodStartTimestamp = Some z; + currentPeriodStartTimestamp = _; } ) -> InProgress { @@ -430,7 +444,7 @@ let matches_of_api_events (e : api_events) = { injury_time1 = x; injury_time2 = y; - period_start_timestamp = z; + period_start_timestamp; }; score = { @@ -438,6 +452,23 @@ let matches_of_api_events (e : api_events) = away_score = m.awayScore.current; }; } + | ( "Awaiting penalties", + "inprogress", + { + injuryTime1 = _; + injuryTime2 = _; + currentPeriodStartTimestamp = _; + } ) -> + InProgress + { + start_timestamp = m.startTimestamp; + half = Penalties; + score = + { + home_score = m.homeScore.current; + away_score = m.awayScore.current; + }; + } | ( "Penalties", "inprogress", { @@ -496,6 +527,9 @@ let matches_of_api_events (e : api_events) = (show_api_time m.time)); }) +(* https://www.sofascore.com/api/v1/unique-tournament/480/season/70070/rounds *) +(* https://www.sofascore.com/api/v1/unique-tournament/480/season/70070/events/round/636/slug/playoff-round *) + let fetch ctx order (* "last" for previous matches "next" for future matches *) = try%lwt