Skip to content

Commit 08fc7a5

Browse files
authored
Merge pull request #15312 from guardian/update-match-info-page-data-model
Update match info page data model
2 parents 10add79 + 5005c9a commit 08fc7a5

8 files changed

Lines changed: 28 additions & 21 deletions

File tree

dotcom-rendering/scripts/jsonSchema/schema.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const program = TJS.getProgramFromFiles(
1818
path.resolve(`${root}/src/frontend/feCricketMatchPage.ts`),
1919
path.resolve(`${root}/src/frontend/feFootballMatchListPage.ts`),
2020
path.resolve(`${root}/src/frontend/feFootballTablesPage.ts`),
21-
path.resolve(`${root}/src/frontend/feFootballMatchPage.ts`),
21+
path.resolve(`${root}/src/frontend/feFootballMatchInfoPage.ts`),
2222
path.resolve(`${root}/src/frontend/feHostedContent.ts`),
2323
],
2424
{
@@ -75,8 +75,8 @@ const schemas = [
7575
file: `${root}/src/frontend/schemas/feCricketMatchPage.json`,
7676
},
7777
{
78-
typeName: 'FEFootballMatchPage',
79-
file: `${root}/src/frontend/schemas/feFootballMatchPage.json`,
78+
typeName: 'FEFootballMatchInfoPage',
79+
file: `${root}/src/frontend/schemas/feFootballMatchInfoPage.json`,
8080
},
8181
{
8282
typeName: 'FEHostedContent',

dotcom-rendering/src/footballMatch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
FEFootballPlayer,
66
FEFootballPlayerEvent,
77
FEFootballTeam,
8-
} from './frontend/feFootballMatchPage';
8+
} from './frontend/feFootballMatchInfoPage';
99
import type { Result } from './lib/result';
1010
import { error, ok } from './lib/result';
1111
import { cleanTeamName } from './sportDataPage';

dotcom-rendering/src/footballMatchStats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
FEFootballPlayer,
77
FEFootballPlayerEvent,
88
FEFootballTeam,
9-
} from './frontend/feFootballMatchPage';
9+
} from './frontend/feFootballMatchInfoPage';
1010
import { parseIntResult } from './lib/parse';
1111
import type { Result } from './lib/result';
1212
import { error, ok } from './lib/result';

dotcom-rendering/src/frontend/feFootballMatchPage.ts renamed to dotcom-rendering/src/frontend/feFootballMatchInfoPage.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type FEFootballMatchStats = {
4242
comments?: string;
4343
};
4444

45-
export type FEFootballMatchPage = FEFootballDataPage & {
45+
export type FEFootballMatchInfoPage = FEFootballDataPage & {
4646
// This field name will need to get changed to matchStats in the future PRs.
4747
// Since this change needs to happen in both frontend and DCAR, and it also
4848
// needs to be backward compatible for a temprary duration, we will handle
@@ -51,4 +51,5 @@ export type FEFootballMatchPage = FEFootballDataPage & {
5151
matchInfo: FEFootballMatch;
5252
group?: FEGroupSummary;
5353
competitionName: string;
54+
matchUrl: string;
5455
};

dotcom-rendering/src/frontend/schemas/feFootballMatchPage.json renamed to dotcom-rendering/src/frontend/schemas/feFootballMatchInfoPage.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,12 +479,16 @@
479479
},
480480
"competitionName": {
481481
"type": "string"
482+
},
483+
"matchUrl": {
484+
"type": "string"
482485
}
483486
},
484487
"required": [
485488
"competitionName",
486489
"footballMatch",
487-
"matchInfo"
490+
"matchInfo",
491+
"matchUrl"
488492
]
489493
}
490494
],

dotcom-rendering/src/model/validate.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import Ajv from 'ajv';
44
import addFormats from 'ajv-formats';
55
import type { FEArticle } from '../frontend/feArticle';
66
import type { FECricketMatchPage } from '../frontend/feCricketMatchPage';
7+
import type { FEFootballMatchInfoPage } from '../frontend/feFootballMatchInfoPage';
78
import type { FEFootballMatchListPage } from '../frontend/feFootballMatchListPage';
8-
import type { FEFootballMatchPage } from '../frontend/feFootballMatchPage';
99
import type { FEFootballTablesPage } from '../frontend/feFootballTablesPage';
1010
import type { FEFront } from '../frontend/feFront';
1111
import type { FEHostedContent } from '../frontend/feHostedContent';
1212
import type { FETagPage } from '../frontend/feTagPage';
1313
import articleSchema from '../frontend/schemas/feArticle.json';
1414
import cricketMatchPageSchema from '../frontend/schemas/feCricketMatchPage.json';
15+
import footballMatchInfoPageSchema from '../frontend/schemas/feFootballMatchInfoPage.json';
1516
import footballMatchListPageSchema from '../frontend/schemas/feFootballMatchListPage.json';
16-
import footballMatchPageSchema from '../frontend/schemas/feFootballMatchPage.json';
1717
import footballTablesPageSchema from '../frontend/schemas/feFootballTablesPage.json';
1818
import frontSchema from '../frontend/schemas/feFront.json';
1919
import hostedContentSchema from '../frontend/schemas/feHostedContent.json';
@@ -55,8 +55,8 @@ const validateFootballTablesPage = ajv.compile<FEFootballTablesPage>(
5555
const validateCricketMatchPage = ajv.compile<FECricketMatchPage>(
5656
cricketMatchPageSchema,
5757
);
58-
const validateFootballMatchPage = ajv.compile<FEFootballMatchPage>(
59-
footballMatchPageSchema,
58+
const validateFootballMatchInfoPage = ajv.compile<FEFootballMatchInfoPage>(
59+
footballMatchInfoPageSchema,
6060
);
6161
const validateHostedContent = ajv.compile<FEHostedContent>(hostedContentSchema);
6262

@@ -176,8 +176,8 @@ export const validateAsCricketMatchPageType = (
176176

177177
export const validateAsFootballMatchPageType = (
178178
data: unknown,
179-
): FEFootballMatchPage => {
180-
if (validateFootballMatchPage(data)) return data;
179+
): FEFootballMatchInfoPage => {
180+
if (validateFootballMatchInfoPage(data)) return data;
181181

182182
const url =
183183
isObject(data) && isObject(data.config) && isString(data.config.pageId)
@@ -186,7 +186,7 @@ export const validateAsFootballMatchPageType = (
186186

187187
throw new TypeError(
188188
`Unable to validate request body for url ${url}.\n
189-
${JSON.stringify(validateFootballMatchPage.errors, null, 2)}`,
189+
${JSON.stringify(validateFootballMatchInfoPage.errors, null, 2)}`,
190190
);
191191
};
192192

dotcom-rendering/src/server/handler.sportDataPage.web.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
} from '../footballTables';
1414
import type { FECricketMatchPage } from '../frontend/feCricketMatchPage';
1515
import type { FEFootballCompetition } from '../frontend/feFootballDataPage';
16+
import type { FEFootballMatchInfoPage } from '../frontend/feFootballMatchInfoPage';
1617
import type { FEFootballMatchListPage } from '../frontend/feFootballMatchListPage';
17-
import type { FEFootballMatchPage } from '../frontend/feFootballMatchPage';
1818
import type { FEFootballTablesPage } from '../frontend/feFootballTablesPage';
1919
import { Pillar } from '../lib/articleFormat';
2020
import { extractNAV } from '../model/extract-nav';
@@ -26,9 +26,9 @@ import {
2626
} from '../model/validate';
2727
import type {
2828
CricketMatchPage,
29+
FootballMatchInfoPage,
2930
FootballMatchListPage,
3031
FootballMatchListPageKind,
31-
FootballMatchSummaryPage,
3232
FootballTablesPage,
3333
Region,
3434
} from '../sportDataPage';
@@ -213,8 +213,8 @@ export const handleCricketMatchPage: RequestHandler = ({ body }, res) => {
213213
};
214214

215215
const parseFEFootballMatch = (
216-
data: FEFootballMatchPage,
217-
): FootballMatchSummaryPage => {
216+
data: FEFootballMatchInfoPage,
217+
): FootballMatchInfoPage => {
218218
const parsedFootballMatch = parseFootballMatch(data.footballMatch);
219219

220220
if (!parsedFootballMatch.ok) {
@@ -253,6 +253,7 @@ const parseFEFootballMatch = (
253253
matchInfo: matchInfo.value,
254254
competitionName: data.competitionName,
255255
group: group?.value,
256+
matchUrl: data.matchUrl,
256257
kind: 'FootballMatchSummary',
257258
nav: {
258259
...extractNAV(data.nav),
@@ -269,7 +270,7 @@ const parseFEFootballMatch = (
269270
};
270271

271272
export const handleFootballMatchPage: RequestHandler = ({ body }, res) => {
272-
const footballMatchPageValidated: FEFootballMatchPage =
273+
const footballMatchPageValidated: FEFootballMatchInfoPage =
273274
validateAsFootballMatchPageType(body);
274275
const parsedFootballMatchData = parseFEFootballMatch(
275276
footballMatchPageValidated,

dotcom-rendering/src/sportDataPage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,13 @@ export type CricketMatchPage = SportPageConfig & {
5151
kind: 'CricketMatch';
5252
};
5353

54-
export type FootballMatchSummaryPage = SportPageConfig & {
54+
export type FootballMatchInfoPage = SportPageConfig & {
5555
match: FootballMatch;
5656
matchStats: FootballMatchStats;
5757
matchInfo: FootballMatchV2;
5858
group?: FootballTableSummary;
5959
competitionName: string;
60+
matchUrl: string;
6061
kind: 'FootballMatchSummary';
6162
};
6263

@@ -71,7 +72,7 @@ export type FootballPageWithRegionsKind = FootballDataWithRegionsPage['kind'];
7172
export type SportDataPage =
7273
| FootballDataWithRegionsPage
7374
| CricketMatchPage
74-
| FootballMatchSummaryPage;
75+
| FootballMatchInfoPage;
7576

7677
export type SportPageKind = SportDataPage['kind'];
7778

0 commit comments

Comments
 (0)