Order in bracket with position, display number

This commit is contained in:
Kalle
2022-04-09 12:41:47 +03:00
parent 5b9a17d3a3
commit 7aef29c47a
6 changed files with 16 additions and 2 deletions

View File

@@ -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,

View File

@@ -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",
},
},
},
},

View File

@@ -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,

View File

@@ -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,

View File

@@ -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;

View File

@@ -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?