Skip to content

Commit

Permalink
chore: Update brackets-manager
Browse files Browse the repository at this point in the history
Updated the `brackets-manager` to the latest version which fixed the bye
completion issue.

Reference: Drarig29/brackets-manager.js#172
  • Loading branch information
Tandashi committed Jun 30, 2023
1 parent 53e8286 commit 0cc9d4b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 46 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@prisma/client": "^4.15.0",
"@twurple/api": "^6.2.1",
"@twurple/auth": "^6.2.1",
"brackets-manager": "^1.5.8",
"brackets-manager": "^1.5.9",
"brackets-prisma-db": "^1.0.0",
"discord.js": "^14.11.0",
"knockoutcity-auth-client": "^1.0.0-alpha.2",
Expand Down
41 changes: 0 additions & 41 deletions src/services/tournament.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { findOrCreateBrawler } from './brawler';
import {
Brawler,
Match,
MatchStatus,
Participant,
Stage,
Team,
Expand Down Expand Up @@ -217,46 +216,6 @@ export async function startTournament(
return stageResult;
}

// Check if we have byes.
// If so we need to mark them as completed.
// See: https://github.com/Drarig29/brackets-manager.js/issues/172
// Can be removed once that bug is fixed.
if (byeCount > 0) {
const results = await Promise.all(
stageResult.data.matches.map((match) => {
if (match.opponent1Result !== null && match.opponent2Result !== null) {
return Success(null);
}

return MatchDao.updateMatch({
where: {
id: match.id,
},
data: {
status: MatchStatus.COMPLETED,
games: {
updateMany: {
where: {
matchId: match.id,
},
data: {
status: MatchStatus.COMPLETED,
},
},
},
},
});
}),
);

if (results.some((r) => r.type === 'error')) {
return Failure(
'internal',
'Could not mark all BYE Matches and Match Games as completed.',
);
}
}

const { rounds } = stageResult.data;
const highestRound = rounds.reduce((acc, cur) => {
if (acc.number < cur.number) {
Expand Down

0 comments on commit 0cc9d4b

Please sign in to comment.