regional teams

This commit is contained in:
yohlo
2026-02-09 23:36:04 -06:00
parent 5dd41d8022
commit 63853f22de
10 changed files with 181 additions and 85 deletions

View File

@@ -7,7 +7,7 @@ export function createMatchesService(pb: PocketBase) {
return {
async getMatch(id: string): Promise<Match | null> {
const result = await pb.collection("matches").getOne(id, {
expand: "tournament, home, away",
expand: "tournament, home, away, home.players, away.players",
});
return transformMatch(result);
},
@@ -19,7 +19,7 @@ export function createMatchesService(pb: PocketBase) {
const result = await pb.collection("matches").getFullList({
filter: `tournament="${match.tournament.id}" && (home_from_lid = ${match.lid} || away_from_lid = ${match.lid}) && bye = false`,
expand: "tournament, home, away",
expand: "tournament, home, away, home.players, away.players",
});
const winnerMatch = result.find(m => (m.home_from_lid === match.lid && !m.home_from_loser) || (m.away_from_lid === match.lid && !m.away_from_loser));
@@ -50,7 +50,7 @@ export function createMatchesService(pb: PocketBase) {
async updateMatch(id: string, data: Partial<MatchInput>): Promise<Match> {
logger.info("PocketBase | Updating match", { id, data });
const result = await pb.collection("matches").update<Match>(id, data, {
expand: 'home, away, tournament'
expand: 'home, away, tournament, home.players, away.players'
});
return transformMatch(result);
},

View File

@@ -126,7 +126,7 @@ export function createPlayersService(pb: PocketBase) {
const result = await pb.collection("matches").getFullList({
filter: `(${teamFilter}) && (status = "ended" || status = "started")`,
sort: "-created",
expand: "tournament,home,away",
expand: "tournament,home,away,home.players,away.players",
});
return result.map((match) => transformMatch(match));

View File

@@ -105,7 +105,7 @@ export function createTeamsService(pb: PocketBase) {
const result = await pb.collection("matches").getFullList({
filter: `(${teamFilter}) && (status = "ended" || status = "started")`,
sort: "-start_time",
expand: "tournament,home,away",
expand: "tournament,home,away,home.players,away.players",
});
return result.map((match) => transformMatch(match));