use short names
This commit is contained in:
parent
d5abe31a3f
commit
86f8051e3b
1 changed files with 13 additions and 5 deletions
16
lib/lib.ml
16
lib/lib.ml
|
|
@ -17,12 +17,18 @@ type api_team_colors = { primary : string; secondary : string; text : string }
|
||||||
type api_team = {
|
type api_team = {
|
||||||
id : int;
|
id : int;
|
||||||
name : string;
|
name : string;
|
||||||
|
short_name : string option; [@key "shortName"] [@yojson.option]
|
||||||
gender : string;
|
gender : string;
|
||||||
teamColors : api_team_colors;
|
teamColors : api_team_colors;
|
||||||
country : api_country;
|
country : api_country;
|
||||||
}
|
}
|
||||||
[@@yojson.allow_extra_fields] [@@deriving yojson, show]
|
[@@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 }
|
type api_tournament_info = { name : string; slug : string }
|
||||||
[@@yojson.allow_extra_fields] [@@deriving yojson, show]
|
[@@yojson.allow_extra_fields] [@@deriving yojson, show]
|
||||||
|
|
||||||
|
|
@ -101,7 +107,6 @@ module Tournament = struct
|
||||||
type t = { context : tournament_scrape_context; matches : match' list }
|
type t = { context : tournament_scrape_context; matches : match' list }
|
||||||
|
|
||||||
let make context matches = { context; matches }
|
let make context matches = { context; matches }
|
||||||
|
|
||||||
let matches { matches; _ } = matches
|
let matches { matches; _ } = matches
|
||||||
|
|
||||||
let pp (day : Unix.tm) (tournament : t) =
|
let pp (day : Unix.tm) (tournament : t) =
|
||||||
|
|
@ -141,8 +146,8 @@ module Tournament = struct
|
||||||
| None -> None
|
| None -> None
|
||||||
| Some timestamp ->
|
| Some timestamp ->
|
||||||
Some
|
Some
|
||||||
(sprintf "%s | %s x %s" timestamp x.home_team.name
|
(sprintf "%s | %s x %s" timestamp (team_name x.home_team) (team_name x.away_team)
|
||||||
x.away_team.name)
|
)
|
||||||
in
|
in
|
||||||
let m =
|
let m =
|
||||||
tournament.matches
|
tournament.matches
|
||||||
|
|
@ -232,7 +237,10 @@ let fetch_matches ctx =
|
||||||
ctx.id ctx.season order
|
ctx.id ctx.season order
|
||||||
|> get |> Yojson.Safe.from_string |> api_events_of_yojson
|
|> get |> Yojson.Safe.from_string |> api_events_of_yojson
|
||||||
|> matches_of_api_events
|
|> 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
|
in
|
||||||
Tournament.make ctx (List.append (g "last") (g "next"))
|
Tournament.make ctx (List.append (g "last") (g "next"))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue