diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index b926258..809cec9 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -10,6 +10,9 @@ import type { RacePickPoints, RacePickPointsAcc, RaceResult, + ScrapedDriverStanding, + ScrapedRaceResult, + ScrapedTeamStanding, SeasonPick, SeasonPickedUser, Substitution, @@ -289,3 +292,42 @@ export const fetch_racepickpointsacc = async ( return racepickpointsacc; }; + +/** + * Fetch all [ScrapedDriverStandings] from the database, ordered ascendingly by position. + */ +export const fetch_scraped_driverstandings = async ( + fetch: (_: any) => Promise, +): Promise => { + const scraped_driverstandings: ScrapedDriverStanding[] = await pb + .collection("scraped_driverstandings") + .getFullList({ fetch: fetch, sort: "+position" }); + + return scraped_driverstandings; +}; + +/** + * Fetch all [ScrapedTeamStandings] from the database, ordered ascendingly by position. + */ +export const fetch_scraped_teamstandings = async ( + fetch: (_: any) => Promise, +): Promise => { + const scraped_teamstandings: ScrapedTeamStanding[] = await pb + .collection("scraped_teamstandings") + .getFullList({ fetch: fetch, sort: "+position" }); + + return scraped_teamstandings; +}; + +/** + * Fetch all [ScrapedRaceResults] from the database, ordered descendingly by race step. + */ +export const fetch_scraped_raceresults = async ( + fetch: (_: any) => Promise, +): Promise => { + const scraped_raceresults: ScrapedRaceResult[] = await pb + .collection("scraped_raceresults") + .getFullList({ fetch: fetch, sort: "-race_step,+position" }); + + return scraped_raceresults; +};