-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add IndyCar and refactor session mapping
- Loading branch information
Showing
10 changed files
with
72 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { getSeriesEvents } from '@/lib/motorsportstats/motorsportstats' | ||
import { GetSessionType } from '@/lib/motorsportstats/types' | ||
import { Series } from '@/series/config' | ||
import Event from '@/types/event' | ||
import { Type } from '@/types/session' | ||
|
||
const SESSION_TYPE_MAP = { | ||
P1: Type.Practice, | ||
P2: Type.Practice, | ||
Q1: Type.Qualifying, | ||
Q2: Type.Qualifying, | ||
Race: Type.Race | ||
const getSessionType: GetSessionType = (sessionCode) => { | ||
if (/^P\d*$/.test(sessionCode)) return Type.Practice | ||
if (/^Q\d*$/.test(sessionCode)) return Type.Qualifying | ||
if (sessionCode === 'Race') return Type.Race | ||
} | ||
|
||
export default async (): Promise<Event[]> => getSeriesEvents(Series.BTCC, SESSION_TYPE_MAP) | ||
export default async (): Promise<Event[]> => getSeriesEvents(Series.BTCC, getSessionType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import { getSeriesEvents } from '@/lib/motorsportstats/motorsportstats' | ||
import { SessionResponse } from '@/lib/motorsportstats/types' | ||
import { GetSessionType, ProcessSessions } from '@/lib/motorsportstats/types' | ||
import { Series } from '@/series/config' | ||
import Event from '@/types/event' | ||
import { Type } from '@/types/session' | ||
import partition from '@/utils/partition' | ||
|
||
const SESSION_TYPE_MAP = { | ||
P1: Type.Practice, | ||
P2: Type.Practice, | ||
P3: Type.Practice, | ||
Q: Type.Qualifying, | ||
Race: Type.Race | ||
const getSessionType: GetSessionType = (sessionCode) => { | ||
if (/^P\d*$/.test(sessionCode)) return Type.Practice | ||
if (sessionCode === 'Q') return Type.Qualifying | ||
if (sessionCode === 'Race') return Type.Race | ||
} | ||
|
||
const groupQualifying = (sessions: SessionResponse[]): SessionResponse[] => { | ||
const groupQualifying: ProcessSessions = (sessions) => { | ||
const [{ 0: firstQualifying, length, [length - 1]: lastQualifying }, otherSessions] = partition(sessions, session => session.shortCode.startsWith('Q')) | ||
|
||
return otherSessions.concat({ uuid: 'q', name: 'Qualifying', shortCode: 'Q', startTimeUtc: firstQualifying.startTimeUtc, endTimeUtc: lastQualifying.endTimeUtc }) | ||
} | ||
|
||
export default async (): Promise<Event[]> => getSeriesEvents(Series.FE, SESSION_TYPE_MAP, groupQualifying) | ||
export default async (): Promise<Event[]> => getSeriesEvents(Series.FE, getSessionType, groupQualifying) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { getSeriesEvents } from '@/lib/motorsportstats/motorsportstats' | ||
import { GetSessionType, ProcessSessions } from '@/lib/motorsportstats/types' | ||
import { Type } from '@/types/session' | ||
import partition from '@/utils/partition' | ||
import { Series } from '../config' | ||
|
||
const getSessionType: GetSessionType = (sessionCode) => { | ||
if (/^P\d*$/.test(sessionCode) || sessionCode === 'FPR' || sessionCode === 'WU') { | ||
return Type.Practice | ||
} | ||
if (sessionCode === 'Q') return Type.Qualifying | ||
if (sessionCode === 'Race') return Type.Race | ||
} | ||
|
||
const groupQualifying: ProcessSessions = (sessions) => { | ||
const [{ 0: firstQualifying, length, [length - 1]: lastQualifying }, otherSessions] = partition(sessions, session => /^Q\d*$/.test(session.shortCode)) | ||
|
||
return otherSessions.concat({ uuid: 'q', name: 'Qualifying', shortCode: 'Q', startTimeUtc: firstQualifying.startTimeUtc, endTimeUtc: lastQualifying.endTimeUtc }) | ||
} | ||
|
||
export default () => getSeriesEvents(Series.IndyCar, getSessionType, groupQualifying) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40a713e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
raceweek – ./
raceweek-appsbytom.vercel.app
raceweek-git-main-appsbytom.vercel.app
raceweek.vercel.app