Skip to content

Commit fa9e508

Browse files
authored
New football models (#14995)
A refactoring of our existing football models, to reduce duplication and allow them to work for upcoming changes to football sportblogs and match report pages. These are not currently being used anywhere. The work to have them replace the existing models, and be used on the aforementioned pages, will happen in future changes.
1 parent e243c2f commit fa9e508

File tree

4 files changed

+140
-0
lines changed

4 files changed

+140
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import type { FootballTeam } from './footballTeam';
2+
3+
/**
4+
* The stats for each team in a given football match.
5+
*/
6+
export type FootballMatchStats = {
7+
homeTeam: FootballMatchTeamWithStats;
8+
awayTeam: FootballMatchTeamWithStats;
9+
};
10+
11+
/**
12+
* Extended stats information about a given team in a football match, including
13+
* a list of players.
14+
*/
15+
type FootballMatchTeamWithStats = FootballTeam & {
16+
abbreviatedName: string;
17+
possession: number;
18+
shotsOnTarget: number;
19+
shotsOffTarget: number;
20+
corners: number;
21+
fouls: number;
22+
players: FootballPlayer[];
23+
statsColour: string;
24+
};
25+
26+
/**
27+
* Information about a player's participation in a given football match.
28+
*/
29+
type FootballPlayer = {
30+
paID: string;
31+
name: string;
32+
substitute: boolean;
33+
shirtNumber: number;
34+
events: PlayerEvent[];
35+
};
36+
37+
/**
38+
* Events involving a particular player in a given football match.
39+
*/
40+
type PlayerEvent = {
41+
kind: 'substitution' | 'booking' | 'dismissal';
42+
minute: number;
43+
};
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import type { FootballTeam } from './footballTeam';
2+
3+
/**
4+
* There are three states a football match can be in.
5+
*
6+
* - Before it starts it's known as a "fixture".
7+
* - While it's in-play we refer to it as "live".
8+
* - Once it's over it's known as a "result".
9+
*/
10+
export type FootballMatch = MatchFixture | LiveMatch | MatchResult;
11+
12+
/**
13+
* Before a match has started we have some information, such as when it's going
14+
* to start and which teams are playing. But we don't have a score or status.
15+
*/
16+
export type MatchFixture = MatchData & {
17+
kind: 'Fixture';
18+
homeTeam: FootballTeam;
19+
awayTeam: FootballTeam;
20+
};
21+
22+
/**
23+
* Once a match has started we have additional information beyond what's
24+
* available for a {@linkcode MatchFixture}, such as the score.
25+
*/
26+
export type LiveMatch = MatchData & {
27+
kind: 'Live';
28+
homeTeam: FootballMatchTeamWithScore;
29+
awayTeam: FootballMatchTeamWithScore;
30+
status: string;
31+
comment: string | undefined;
32+
};
33+
34+
/**
35+
* When a match is over, we have much the same information as when it's a
36+
* {@linkcode LiveMatch}, such as the score. The status is always "full-time"
37+
* (FT), so we don't need a property for that.
38+
*/
39+
export type MatchResult = MatchData & {
40+
kind: 'Result';
41+
homeTeam: FootballMatchTeamWithScore;
42+
awayTeam: FootballMatchTeamWithScore;
43+
comment: string | undefined;
44+
};
45+
46+
/**
47+
* For all football matches we should know what the PA ID is and when it's
48+
* scheduled to kick off.
49+
*/
50+
type MatchData = {
51+
paId: string;
52+
kickOff: Date;
53+
venue: string;
54+
};
55+
56+
/**
57+
* Once a match has started, we can bundle together information about a team,
58+
* such as its name, with its score and which players have scored.
59+
*/
60+
type FootballMatchTeamWithScore = FootballTeam & {
61+
score: number;
62+
scorers: string[];
63+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { FootballMatch } from './footballMatchV2';
2+
3+
/**
4+
* A collection of football matches happening across one or more days, where
5+
* each day is represented by a separate item in the list.
6+
*/
7+
export type FootballMatches = FootballCompetitionsOnDay[];
8+
9+
/**
10+
* All the football competitions with matches on a given day.
11+
*/
12+
type FootballCompetitionsOnDay = {
13+
day: Date;
14+
competitions: FootballCompetition[];
15+
};
16+
17+
/**
18+
* A selection of football matches happening as part of a given competition.
19+
*/
20+
type FootballCompetition = {
21+
id: string;
22+
tag: string;
23+
name: string;
24+
nation: string;
25+
matches: FootballMatch[];
26+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* The basic information we should have about all football teams is their PA ID
3+
* and their name.
4+
*/
5+
export type FootballTeam = {
6+
name: string;
7+
paID: string;
8+
};

0 commit comments

Comments
 (0)