Lib: Add fetcher for seasonpicks
This commit is contained in:
@ -6,6 +6,7 @@ import type {
|
|||||||
Race,
|
Race,
|
||||||
RacePick,
|
RacePick,
|
||||||
RaceResult,
|
RaceResult,
|
||||||
|
SeasonPick,
|
||||||
Substitution,
|
Substitution,
|
||||||
Team,
|
Team,
|
||||||
User,
|
User,
|
||||||
@ -142,7 +143,6 @@ export const fetch_currentrace = async (
|
|||||||
export const fetch_racepicks = async (
|
export const fetch_racepicks = async (
|
||||||
fetch: (_: any) => Promise<Response>,
|
fetch: (_: any) => Promise<Response>,
|
||||||
): Promise<RacePick[]> => {
|
): Promise<RacePick[]> => {
|
||||||
// Don't expand race/pxx/dnf since we already fetched those
|
|
||||||
const racepicks: RacePick[] = await pb
|
const racepicks: RacePick[] = await pb
|
||||||
.collection("racepicks")
|
.collection("racepicks")
|
||||||
.getFullList({ fetch: fetch, expand: "user" });
|
.getFullList({ fetch: fetch, expand: "user" });
|
||||||
@ -150,6 +150,19 @@ export const fetch_racepicks = async (
|
|||||||
return racepicks;
|
return racepicks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch all [SeasonPicks] from the database
|
||||||
|
*/
|
||||||
|
export const fetch_seasonpicks = async (
|
||||||
|
fetch: (_: any) => Promise<Response>,
|
||||||
|
): Promise<SeasonPick[]> => {
|
||||||
|
const seasonpicks: SeasonPick[] = await pb
|
||||||
|
.collection("seasonpicks")
|
||||||
|
.getFullList({ fetch: fetch, expand: "user" });
|
||||||
|
|
||||||
|
return seasonpicks;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch all [Users] (with the extra field "picked" that is truthy
|
* Fetch all [Users] (with the extra field "picked" that is truthy
|
||||||
* if the user already picked for the current race)
|
* if the user already picked for the current race)
|
||||||
|
|||||||
Reference in New Issue
Block a user