Closed Tandashi closed 1 year ago
Now I have the 1st Match in the Semi Finals which has its Match marked as Ready as well as its MatchGames marked as Ready. This is correct so far but it was also created like this initially. The 2nd Match in the Semi Finals (P2 vs P3) has also the Match marked as Ready (also still correct) but its MatchGames are still marked as Waiting. Meaning the MatchGames have not updated their status but the Match has. Do I have to update in some other way / am I misunderstanding something?
It seems to work with the Json DB on my side... 🤔 Note that in my example, all IDs start from 0:
await manager.create({
name: 'Some Title',
tournamentId: 0,
type: 'single_elimination',
seeding: ['P1', 'P2', 'P3', 'P4', 'P5', null, null, null],
settings: {
grandFinal: 'simple',
balanceByes: true,
matchesChildCount: 3,
},
});
const semiFinalMatchId = (await manager.find.match(0, 2, 2)).id; // Second Match in the Semi Finals
await manager.update.matchGame({
id: 6, // First Match Game of the 3rd Match in Round 1
opponent1: { score: 16, result: 'win' },
opponent2: { score: 12 },
});
console.log(await manager.find.matchGame({ parent_id: semiFinalMatchId, number: 1 }));
// {
// id: 15,
// number: 1,
// stage_id: 0,
// parent_id: 5,
// status: 1,
// opponent1: { id: null },
// opponent2: { id: 2 }
// }
await manager.update.matchGame({
id: 7, // Second Match Game of the 3rd Match in Round 1
opponent1: { score: 16, result: 'win' },
opponent2: { score: 12 },
});
console.log(await manager.find.matchGame({ parent_id: semiFinalMatchId, number: 1 }));
// {
// id: 15,
// number: 1,
// stage_id: 0,
// parent_id: 5,
// status: 2,
// opponent1: { id: 1 },
// opponent2: { id: 2 }
// }
The part of the code that is responsible to update the match games is this one:
Which corresponds to this part of your prisma implementation. Maybe you should debug this part.
Yeah with your example it works... Weird must have messed something up when trying with the JsonDatabase
to confirm.
My bad...
Will debug the issue in the SQL implementation and make a PR for fix it :)
Thank you, best of luck to find the bug 🙏
Setup
(See also Example below)
Assume I create a stage (setup described below). I then update the
MatchGames
for the firstMatch
withmanager.update.matchGame
. The score for the first and secondMatchGame
would be2 | 0
meaning opponent 1 has won the best of 3 and advances to the next round.The following I passed to the create Method for creating a stage:
The participants have been created beforehand and I am just linking them in the seeding.
After the creation of the Stage:
After updating the
MatchGames
for the firstMatch
:The Issue
Now I have the 1st
Match
in the Semi Finals which has itsMatch
marked asReady
as well as itsMatchGames
marked asReady
. This is correct so far but it was also created like this initially. The 2ndMatch
in the Semi Finals (P2 vs P3) has also theMatch
marked asReady
(also still correct) but itsMatchGames
are still marked asWaiting
. Meaning theMatchGames
have not updated their status but theMatch
has. Do I have to update in some other way / am I misunderstanding something?Also the last
MatchGame
of the firstMatch
in Round 1 is still marked asReady
although theMatch
is marked asCompleted
(which is correct since opponent 1 in both occasions has won twice winning the bo3). Maybe that is somehow related to the issue? Further more in the Example the Participant is alsonull
but in theMatch
both Participants are present.My current solution is that I prepare the
Match
by manually marking theMatchGames
asReady
when theMatch
is also marked asReady
. Not sure if that is intended behaviour though.Example