mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-09-30 07:12:36 -05:00
Order in bracket with position, display number
This commit is contained in:
@@ -243,6 +243,7 @@ export interface TournamentRoundForDB {
|
||||
matches: {
|
||||
id: string;
|
||||
number: number;
|
||||
position: number;
|
||||
winnerDestinationMatchId?: string;
|
||||
loserDestinationMatchId?: string;
|
||||
participants: {
|
||||
@@ -282,6 +283,7 @@ export function tournamentRoundsForDB({
|
||||
const matches = round.map((match) => {
|
||||
return {
|
||||
id: match.id,
|
||||
position: match.position,
|
||||
number: match.number,
|
||||
winnerDestinationMatchId: match.winnerDestinationMatch?.id,
|
||||
loserDestinationMatchId: match.loserDestinationMatch?.id,
|
||||
|
||||
@@ -19,6 +19,7 @@ export function findById(bracketId: string) {
|
||||
matches: {
|
||||
select: {
|
||||
id: true,
|
||||
number: true,
|
||||
position: true,
|
||||
winnerDestinationMatchId: true,
|
||||
loserDestinationMatchId: true,
|
||||
@@ -39,6 +40,9 @@ export function findById(bracketId: string) {
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
position: "asc",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -108,7 +108,8 @@ function modifyRounds(
|
||||
]
|
||||
: undefined;
|
||||
return {
|
||||
number: match.position,
|
||||
// TODO: match.number could be made mandatory in DB and this would become redundant
|
||||
number: match.number ?? match.position,
|
||||
id: match.id,
|
||||
winnerDestinationMatchId: match.winnerDestinationMatchId,
|
||||
loserDestinationMatchId: match.loserDestinationMatchId,
|
||||
|
||||
@@ -126,7 +126,8 @@ export async function createTournamentRounds({
|
||||
data: rounds.flatMap((round) => {
|
||||
return round.matches.map((match) => ({
|
||||
id: match.id,
|
||||
position: match.number,
|
||||
number: match.number,
|
||||
position: match.position,
|
||||
roundId: round.id,
|
||||
winnerDestinationMatchId: match.winnerDestinationMatchId,
|
||||
loserDestinationMatchId: match.loserDestinationMatchId,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "TournamentMatch" ADD COLUMN "number" INTEGER;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "GameDetail" ADD CONSTRAINT "GameDetail_lfgStageId_fkey" FOREIGN KEY ("lfgStageId") REFERENCES "LfgGroupMatchStage"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -168,6 +168,7 @@ model TournamentRoundStage {
|
||||
model TournamentMatch {
|
||||
id String @id @default(uuid())
|
||||
roundId String
|
||||
number Int?
|
||||
position Int
|
||||
// for SE/DE destination based on the result - if no winner destination then winner has won the tournament, if no loser destination loser is eliminated
|
||||
winnerDestinationMatchId String?
|
||||
|
||||
Reference in New Issue
Block a user