use short names
This commit is contained in:
parent
d5abe31a3f
commit
86f8051e3b
1 changed files with 13 additions and 5 deletions
18
lib/lib.ml
18
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"))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue