working runner w/o spotify
This commit is contained in:
323
brackets/11.json
Normal file
323
brackets/11.json
Normal file
@@ -0,0 +1,323 @@
|
||||
{
|
||||
"winners": [
|
||||
[
|
||||
{
|
||||
"lid": 0,
|
||||
"round": 0,
|
||||
"order": null,
|
||||
"bye": true,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 1
|
||||
},
|
||||
{
|
||||
"lid": 1,
|
||||
"round": 0,
|
||||
"order": 1,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 8,
|
||||
"away_seed": 9,
|
||||
"away_from_lid": null,
|
||||
"away_from_loser": null,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 2,
|
||||
"round": 0,
|
||||
"order": null,
|
||||
"bye": true,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 4
|
||||
},
|
||||
{
|
||||
"lid": 3,
|
||||
"round": 0,
|
||||
"order": null,
|
||||
"bye": true,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 5
|
||||
},
|
||||
{
|
||||
"lid": 4,
|
||||
"round": 0,
|
||||
"order": null,
|
||||
"bye": true,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 2
|
||||
},
|
||||
{
|
||||
"lid": 5,
|
||||
"round": 0,
|
||||
"order": 2,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 7,
|
||||
"away_seed": 10,
|
||||
"away_from_lid": null,
|
||||
"away_from_loser": null,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 6,
|
||||
"round": 0,
|
||||
"order": null,
|
||||
"bye": true,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 3
|
||||
},
|
||||
{
|
||||
"lid": 7,
|
||||
"round": 0,
|
||||
"order": 3,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 6,
|
||||
"away_seed": 11,
|
||||
"away_from_lid": null,
|
||||
"away_from_loser": null,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 8,
|
||||
"round": 1,
|
||||
"order": 5,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 1,
|
||||
"away_from_lid": 1,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 9,
|
||||
"round": 1,
|
||||
"order": 4,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 4,
|
||||
"away_seed": 5,
|
||||
"away_from_lid": null,
|
||||
"away_from_loser": null,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 10,
|
||||
"round": 1,
|
||||
"order": 6,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 2,
|
||||
"away_from_lid": 5,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 11,
|
||||
"round": 1,
|
||||
"order": 7,
|
||||
"bye": false,
|
||||
"home_from_lid": null,
|
||||
"home_from_loser": null,
|
||||
"home_seed": 3,
|
||||
"away_from_lid": 7,
|
||||
"away_from_loser": null,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 18,
|
||||
"round": 2,
|
||||
"order": 13,
|
||||
"bye": false,
|
||||
"home_from_lid": 8,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 9,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 19,
|
||||
"round": 2,
|
||||
"order": 14,
|
||||
"bye": false,
|
||||
"home_from_lid": 10,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 11,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 23,
|
||||
"round": 3,
|
||||
"order": 16,
|
||||
"bye": false,
|
||||
"home_from_lid": 18,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 19,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 25,
|
||||
"round": 4,
|
||||
"order": 18,
|
||||
"bye": false,
|
||||
"home_from_lid": 23,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 24,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 26,
|
||||
"round": 5,
|
||||
"order": 19,
|
||||
"bye": false,
|
||||
"home_from_lid": 25,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 25,
|
||||
"away_from_loser": true,
|
||||
"reset": true
|
||||
}
|
||||
]
|
||||
],
|
||||
"losers": [
|
||||
[
|
||||
{
|
||||
"lid": 12,
|
||||
"round": 0,
|
||||
"order": null,
|
||||
"bye": true,
|
||||
"home_from_lid": 10,
|
||||
"home_from_loser": true
|
||||
},
|
||||
{
|
||||
"lid": 13,
|
||||
"round": 0,
|
||||
"order": 10,
|
||||
"bye": false,
|
||||
"home_from_lid": 11,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 1,
|
||||
"away_from_loser": true,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 14,
|
||||
"round": 0,
|
||||
"order": 8,
|
||||
"bye": false,
|
||||
"home_from_lid": 9,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 5,
|
||||
"away_from_loser": true,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 15,
|
||||
"round": 0,
|
||||
"order": 9,
|
||||
"bye": false,
|
||||
"home_from_lid": 8,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 7,
|
||||
"away_from_loser": true,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 16,
|
||||
"round": 1,
|
||||
"order": 9,
|
||||
"bye": false,
|
||||
"home_from_lid": 10,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 13,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 17,
|
||||
"round": 1,
|
||||
"order": 10,
|
||||
"bye": false,
|
||||
"home_from_lid": 14,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 15,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 20,
|
||||
"round": 2,
|
||||
"order": 13,
|
||||
"bye": false,
|
||||
"home_from_lid": 18,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 16,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
},
|
||||
{
|
||||
"lid": 21,
|
||||
"round": 2,
|
||||
"order": 14,
|
||||
"bye": false,
|
||||
"home_from_lid": 19,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 17,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 22,
|
||||
"round": 3,
|
||||
"order": 15,
|
||||
"bye": false,
|
||||
"home_from_lid": 20,
|
||||
"home_from_loser": false,
|
||||
"away_from_lid": 21,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
],
|
||||
[
|
||||
{
|
||||
"lid": 24,
|
||||
"round": 4,
|
||||
"order": 17,
|
||||
"bye": false,
|
||||
"home_from_lid": 23,
|
||||
"home_from_loser": true,
|
||||
"away_from_lid": 22,
|
||||
"away_from_loser": false,
|
||||
"reset": false
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Button, TextInput, Stack, Group, Text, Flex, Divider } from "@mantine/core";
|
||||
import { Button, TextInput, Stack, Group, Text, Flex, Divider, NumberInput } from "@mantine/core";
|
||||
import { useForm } from "@mantine/form";
|
||||
import { Match } from "@/features/matches/types";
|
||||
|
||||
@@ -92,11 +92,10 @@ export const MatchForm: React.FC<MatchFormProps> = ({
|
||||
</Text>))
|
||||
}
|
||||
</Stack>
|
||||
<TextInput
|
||||
<NumberInput
|
||||
ml='auto'
|
||||
type="number"
|
||||
min={0}
|
||||
w={50}
|
||||
w={70}
|
||||
ta="center"
|
||||
key={form.key("home_cups")}
|
||||
{...form.getInputProps("home_cups")}
|
||||
@@ -116,11 +115,10 @@ export const MatchForm: React.FC<MatchFormProps> = ({
|
||||
</Text>))
|
||||
}
|
||||
</Stack>
|
||||
<TextInput
|
||||
<NumberInput
|
||||
ml='auto'
|
||||
ta="center"
|
||||
w={50}
|
||||
type="number"
|
||||
w={70}
|
||||
min={0}
|
||||
key={form.key("away_cups")}
|
||||
{...form.getInputProps("away_cups")}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* Imports saved json dumps of bracket generation from a python script that I didn't prioritize converting to TS
|
||||
*/
|
||||
import b10 from "../../../../brackets/10.json";
|
||||
import b11 from "../../../../brackets/11.json";
|
||||
import b12 from "../../../../brackets/12.json";
|
||||
import b13 from "../../../../brackets/13.json";
|
||||
import b14 from "../../../../brackets/14.json";
|
||||
@@ -12,6 +14,8 @@ import b19 from "../../../../brackets/19.json";
|
||||
import b20 from "../../../../brackets/20.json";
|
||||
|
||||
export default {
|
||||
10: b10,
|
||||
11: b11,
|
||||
12: b12,
|
||||
13: b13,
|
||||
14: b14,
|
||||
|
||||
@@ -184,6 +184,9 @@ export const endMatch = createServerFn()
|
||||
const matchLoser = home_cups < away_cups ? match.home : match.away;
|
||||
if (!matchWinner || !matchLoser) throw new Error("Something went wrong");
|
||||
|
||||
console.log(matchWinner)
|
||||
console.log(matchLoser)
|
||||
|
||||
// winner -> where to send match winner to, loser same
|
||||
const { winner, loser } = await pbAdmin.getChildMatches(matchId);
|
||||
|
||||
@@ -207,7 +210,7 @@ export const endMatch = createServerFn()
|
||||
// advance bracket
|
||||
if (winner) {
|
||||
await pbAdmin.updateMatch(winner.id, {
|
||||
[winner.home_from_lid === match.lid ? "home" : "away"]: matchWinner,
|
||||
[winner.home_from_lid === match.lid ? "home" : "away"]: matchWinner.id,
|
||||
status:
|
||||
(winner.home_from_lid === match.lid && winner.away) ||
|
||||
(winner.away_from_lid === match.lid && winner.home)
|
||||
@@ -218,7 +221,7 @@ export const endMatch = createServerFn()
|
||||
|
||||
if (loser) {
|
||||
await pbAdmin.updateMatch(loser.id, {
|
||||
[loser.home_from_lid === match.lid ? "home" : "away"]: matchLoser,
|
||||
[loser.home_from_lid === match.lid ? "home" : "away"]: matchLoser.id,
|
||||
status:
|
||||
(loser.home_from_lid === match.lid && loser.away) ||
|
||||
(loser.away_from_lid === match.lid && loser.home)
|
||||
|
||||
@@ -20,7 +20,7 @@ export function createMatchesService(pb: PocketBase) {
|
||||
if (!match) throw new Error("Match not found")
|
||||
|
||||
const result = await pb.collection("matches").getFullList({
|
||||
filter: `tournament="${match.tournament.id}" && (home_from_lid = ${match.lid} || away_from_lid = ${match.lid})`,
|
||||
filter: `tournament="${match.tournament.id}" && (home_from_lid = ${match.lid} || away_from_lid = ${match.lid}) && bye = false`,
|
||||
expand: "tournament, home, away",
|
||||
});
|
||||
|
||||
@@ -51,8 +51,10 @@ 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);
|
||||
return result;
|
||||
const result = await pb.collection("matches").update<Match>(id, data, {
|
||||
expand: 'home, away'
|
||||
});
|
||||
return transformMatch(result);
|
||||
},
|
||||
|
||||
async deleteMatch(id: string): Promise<void> {
|
||||
|
||||
@@ -44,9 +44,9 @@ export const transformMatch = (record: any): Match => {
|
||||
away_from_loser: record.away_from_loser,
|
||||
is_losers_bracket: record.is_losers_bracket,
|
||||
status: record.status || "tbd",
|
||||
tournament: transformTournamentInfo(record.expand?.tournament),
|
||||
home: record.expand?.home ? transformTeamInfo(record.expand.home) : undefined,
|
||||
away: record.expand?.away ? transformTeamInfo(record.expand.away) : undefined,
|
||||
tournament: record.expand?.tournament ? transformTournamentInfo(record.expand?.tournament) : record.tournament,
|
||||
home: record.expand?.home ? transformTeamInfo(record.expand.home) : record.home,
|
||||
away: record.expand?.away ? transformTeamInfo(record.expand.away) : record.away,
|
||||
created: record.created,
|
||||
updated: record.updated,
|
||||
home_seed: record.home_seed,
|
||||
|
||||
Reference in New Issue
Block a user