From d54ee01227114bd8dd6148544a2c65ae2e7b96d5 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Sat, 7 Jun 2025 19:58:34 +0200 Subject: [PATCH] Lib: Update fetchers and schema after database changes --- src/lib/fetch.ts | 16 +++++++++++++++- src/lib/schema.ts | 10 ++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/lib/fetch.ts b/src/lib/fetch.ts index 809cec9..8f32779 100644 --- a/src/lib/fetch.ts +++ b/src/lib/fetch.ts @@ -9,6 +9,7 @@ import type { RacePick, RacePickPoints, RacePickPointsAcc, + RacePickPointsTotal, RaceResult, ScrapedDriverStanding, ScrapedRaceResult, @@ -281,7 +282,7 @@ export const fetch_racepickpoints = async ( }; /** - * Fetch all [RacePickPointsAcc] from the database, ordered descendingly by total points. + * Fetch all [RacePickPointsAcc] from the database, ordered ascendingly by step. */ export const fetch_racepickpointsacc = async ( fetch: (_: any) => Promise, @@ -293,6 +294,19 @@ export const fetch_racepickpointsacc = async ( return racepickpointsacc; }; +/** + * Fetch all [RacePickPointsTotal] from the database, ordered descendingly by total points. + */ +export const fetch_racepickpointstotal = async ( + fetch: (_: any) => Promise, +): Promise => { + const racepickpointstotal: RacePickPointsTotal[] = await pb + .collection("racepickpointstotal") + .getFullList({ fetch: fetch }); + + return racepickpointstotal; +}; + /** * Fetch all [ScrapedDriverStandings] from the database, ordered ascendingly by position. */ diff --git a/src/lib/schema.ts b/src/lib/schema.ts index 025236c..e088425 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -140,11 +140,21 @@ export interface RacePickPoints { } export interface RacePickPointsAcc { + id: string; + user: string; + step: number; + acc_pxx_points: number; + acc_dnf_points: number; + acc_points: number; +} + +export interface RacePickPointsTotal { id: string; user: string; total_pxx_points: number; total_dnf_points: number; total_points: number; + total_points_per_pick: number; } // Scraped Data