File tree Expand file tree Collapse file tree 5 files changed +251
-3
lines changed
Expand file tree Collapse file tree 5 files changed +251
-3
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,9 @@ type MissingScore = {
6262
6363type ParserError = MissingScore ;
6464
65- const parseTable = ( feGroup : FEGroup ) : Result < ParserError , FootballTable > =>
65+ export const parseTable = (
66+ feGroup : FEGroup ,
67+ ) : Result < ParserError , FootballTable > =>
6668 parseEntries ( feGroup . entries ) . map ( ( entries ) => ( {
6769 groupName : feGroup . round . name ,
6870 entries : entries . sort ( ( a , b ) => a . position - b . position ) ,
Original file line number Diff line number Diff line change 11import type { FEFootballDataPage } from './feFootballDataPage' ;
2+ import { type FEGroup } from './feFootballTablesPage' ;
23
34export type FEFootballPlayerEvent = {
45 eventTime : string ;
@@ -42,4 +43,5 @@ export type FEFootballMatch = {
4243
4344export type FEFootballMatchPage = FEFootballDataPage & {
4445 footballMatch : FEFootballMatch ;
46+ group ?: FEGroup ;
4547} ;
Original file line number Diff line number Diff line change 294294 " id" ,
295295 " status"
296296 ]
297+ },
298+ "group" : {
299+ "type" : " object" ,
300+ "properties" : {
301+ "round" : {
302+ "type" : " object" ,
303+ "properties" : {
304+ "roundNumber" : {
305+ "type" : " string"
306+ },
307+ "name" : {
308+ "type" : " string"
309+ }
310+ },
311+ "required" : [
312+ " roundNumber"
313+ ]
314+ },
315+ "entries" : {
316+ "type" : " array" ,
317+ "items" : {
318+ "type" : " object" ,
319+ "properties" : {
320+ "stageNumber" : {
321+ "type" : " string"
322+ },
323+ "round" : {
324+ "type" : " object" ,
325+ "properties" : {
326+ "roundNumber" : {
327+ "type" : " string"
328+ },
329+ "name" : {
330+ "type" : " string"
331+ }
332+ },
333+ "required" : [
334+ " roundNumber"
335+ ]
336+ },
337+ "team" : {
338+ "type" : " object" ,
339+ "properties" : {
340+ "id" : {
341+ "type" : " string"
342+ },
343+ "name" : {
344+ "type" : " string"
345+ },
346+ "rank" : {
347+ "type" : " number"
348+ },
349+ "total" : {
350+ "type" : " object" ,
351+ "properties" : {
352+ "played" : {
353+ "type" : " number"
354+ },
355+ "won" : {
356+ "type" : " number"
357+ },
358+ "drawn" : {
359+ "type" : " number"
360+ },
361+ "lost" : {
362+ "type" : " number"
363+ },
364+ "goalsFor" : {
365+ "type" : " number"
366+ },
367+ "goalsAgainst" : {
368+ "type" : " number"
369+ }
370+ },
371+ "required" : [
372+ " drawn" ,
373+ " goalsAgainst" ,
374+ " goalsFor" ,
375+ " lost" ,
376+ " played" ,
377+ " won"
378+ ]
379+ },
380+ "home" : {
381+ "type" : " object" ,
382+ "properties" : {
383+ "played" : {
384+ "type" : " number"
385+ },
386+ "won" : {
387+ "type" : " number"
388+ },
389+ "drawn" : {
390+ "type" : " number"
391+ },
392+ "lost" : {
393+ "type" : " number"
394+ },
395+ "goalsFor" : {
396+ "type" : " number"
397+ },
398+ "goalsAgainst" : {
399+ "type" : " number"
400+ }
401+ },
402+ "required" : [
403+ " drawn" ,
404+ " goalsAgainst" ,
405+ " goalsFor" ,
406+ " lost" ,
407+ " played" ,
408+ " won"
409+ ]
410+ },
411+ "away" : {
412+ "type" : " object" ,
413+ "properties" : {
414+ "played" : {
415+ "type" : " number"
416+ },
417+ "won" : {
418+ "type" : " number"
419+ },
420+ "drawn" : {
421+ "type" : " number"
422+ },
423+ "lost" : {
424+ "type" : " number"
425+ },
426+ "goalsFor" : {
427+ "type" : " number"
428+ },
429+ "goalsAgainst" : {
430+ "type" : " number"
431+ }
432+ },
433+ "required" : [
434+ " drawn" ,
435+ " goalsAgainst" ,
436+ " goalsFor" ,
437+ " lost" ,
438+ " played" ,
439+ " won"
440+ ]
441+ },
442+ "goalDifference" : {
443+ "type" : " number"
444+ },
445+ "points" : {
446+ "type" : " number"
447+ }
448+ },
449+ "required" : [
450+ " away" ,
451+ " goalDifference" ,
452+ " home" ,
453+ " id" ,
454+ " name" ,
455+ " points" ,
456+ " rank" ,
457+ " total"
458+ ]
459+ },
460+ "teamUrl" : {
461+ "type" : " string"
462+ },
463+ "results" : {
464+ "type" : " array" ,
465+ "items" : {
466+ "type" : " object" ,
467+ "properties" : {
468+ "matchId" : {
469+ "type" : " string"
470+ },
471+ "self" : {
472+ "type" : " object" ,
473+ "properties" : {
474+ "id" : {
475+ "type" : " string"
476+ },
477+ "name" : {
478+ "type" : " string"
479+ },
480+ "score" : {
481+ "type" : " number"
482+ }
483+ },
484+ "required" : [
485+ " id" ,
486+ " name"
487+ ]
488+ },
489+ "foe" : {
490+ "type" : " object" ,
491+ "properties" : {
492+ "id" : {
493+ "type" : " string"
494+ },
495+ "name" : {
496+ "type" : " string"
497+ },
498+ "score" : {
499+ "type" : " number"
500+ }
501+ },
502+ "required" : [
503+ " id" ,
504+ " name"
505+ ]
506+ }
507+ },
508+ "required" : [
509+ " foe" ,
510+ " matchId" ,
511+ " self"
512+ ]
513+ }
514+ }
515+ },
516+ "required" : [
517+ " results" ,
518+ " round" ,
519+ " stageNumber" ,
520+ " team"
521+ ]
522+ }
523+ }
524+ },
525+ "required" : [
526+ " entries" ,
527+ " round"
528+ ]
297529 }
298530 },
299531 "required" : [
Original file line number Diff line number Diff line change 55 getParserErrorMessage ,
66 parse as parseFootballMatches ,
77} from '../footballMatches' ;
8- import { parse as parseFootballTables } from '../footballTables' ;
8+ import { parse as parseFootballTables , parseTable } from '../footballTables' ;
99import type { FECricketMatchPage } from '../frontend/feCricketMatchPage' ;
1010import type { FEFootballCompetition } from '../frontend/feFootballDataPage' ;
1111import type { FEFootballMatchListPage } from '../frontend/feFootballMatchListPage' ;
@@ -216,15 +216,23 @@ const parseFEFootballMatch = (
216216 data : FEFootballMatchPage ,
217217) : FootballMatchSummaryPage => {
218218 const parsedFootballMatch = parseFootballMatch ( data . footballMatch ) ;
219+ const group = data . group && parseTable ( data . group ) ;
219220
220221 if ( ! parsedFootballMatch . ok ) {
221222 throw new Error (
222223 `Failed to parse football match: ${ parsedFootballMatch . error . kind } ${ parsedFootballMatch . error . message } ` ,
223224 ) ;
224225 }
225226
227+ if ( group && ! group . ok ) {
228+ throw new Error (
229+ `Failed to parse football league table group: ${ group . error . kind } ${ group . error . message } ` ,
230+ ) ;
231+ }
232+
226233 return {
227234 match : parsedFootballMatch . value ,
235+ group : group ?. value ,
228236 kind : 'FootballMatchSummary' ,
229237 nav : {
230238 ...extractNAV ( data . nav ) ,
Original file line number Diff line number Diff line change 11import type { CricketMatch } from './cricketMatch' ;
22import type { FootballMatch } from './footballMatch' ;
33import type { FootballMatches } from './footballMatches' ;
4- import type { FootballTableCompetitions } from './footballTables' ;
4+ import type {
5+ FootballTable ,
6+ FootballTableCompetitions ,
7+ } from './footballTables' ;
58import type { FESportPageConfig } from './frontend/feFootballDataPage' ;
69import type { EditionId } from './lib/edition' ;
710import type { NavType } from './model/extract-nav' ;
@@ -48,6 +51,7 @@ export type CricketMatchPage = SportPageConfig & {
4851
4952export type FootballMatchSummaryPage = SportPageConfig & {
5053 match : FootballMatch ;
54+ group ?: FootballTable ;
5155 kind : 'FootballMatchSummary' ;
5256} ;
5357
You can’t perform that action at this time.
0 commit comments