From 86f8051e3b93c2b1e6fbcfb3532a3953f0393068 Mon Sep 17 00:00:00 2001 From: silva guimaraes Date: Sat, 12 Jul 2025 14:41:48 -0300 Subject: [PATCH] use short names --- lib/lib.ml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/lib.ml b/lib/lib.ml index ebb228d..240f1e7 100644 --- a/lib/lib.ml +++ b/lib/lib.ml @@ -17,12 +17,18 @@ type api_team_colors = { primary : string; secondary : string; text : string } type api_team = { id : int; name : string; + short_name : string option; [@key "shortName"] [@yojson.option] gender : string; teamColors : api_team_colors; country : api_country; } [@@yojson.allow_extra_fields] [@@deriving yojson, show] +let team_name x = + match x.short_name with + | Some x -> x + | None -> x.name + type api_tournament_info = { name : string; slug : string } [@@yojson.allow_extra_fields] [@@deriving yojson, show] @@ -101,8 +107,7 @@ module Tournament = struct type t = { context : tournament_scrape_context; matches : match' list } let make context matches = { context; matches } - - let matches { matches; _} = matches + let matches { matches; _ } = matches let pp (day : Unix.tm) (tournament : t) = let format_timestamp x = @@ -141,8 +146,8 @@ module Tournament = struct | None -> None | Some timestamp -> Some - (sprintf "%s | %s x %s" timestamp x.home_team.name - x.away_team.name) + (sprintf "%s | %s x %s" timestamp (team_name x.home_team) (team_name x.away_team) + ) in let m = tournament.matches @@ -232,7 +237,10 @@ let fetch_matches ctx = ctx.id ctx.season order |> get |> Yojson.Safe.from_string |> api_events_of_yojson |> matches_of_api_events - with Status_Not_found -> [] + with + | Status_Not_found -> [] + | Ppx_yojson_conv_lib__Yojson_conv.Of_yojson_error (exn, _) -> + failwith @@ Printexc.to_string exn in Tournament.make ctx (List.append (g "last") (g "next"))