Harden match and tournament code concurrency

This commit is contained in:
dahyeon committed 2026-06-27 12:28:05 -07:00
1 parent 292e37aaac
commit df7dcd3a9c
9 files changed
+2339 -128

No files matched your search

+29 -3
View File
@@ -1492,10 +1492,36 @@ export const TournamentCodeSchema = new Schema<TournamentCode>(
TournamentCodeSchema.index({ code: 1 }, { unique: true });
TournamentCodeSchema.index({ state: 1, expiresAt: 1 });
TournamentCodeSchema.index({ matchId: 1, gameNumber: 1 });
TournamentCodeSchema.index({ matchId: 1, bracketMatchId: 1 }, { sparse: true });
TournamentCodeSchema.index(
{ matchId: 1, gameNumber: 1 },
{
unique: true,
partialFilterExpression: {
matchId: { $exists: true },
gameNumber: { $exists: true },
state: { $in: ['reserved', 'used'] },
},
},
);
TournamentCodeSchema.index(
{ matchId: 1, bracketMatchId: 1 },
{
unique: true,
partialFilterExpression: {
matchId: { $exists: true },
bracketMatchId: { $exists: true },
state: { $in: ['reserved', 'used'] },
},
},
);
TournamentCodeSchema.index({ state: 1, uploadedAt: -1 });
TournamentCodeSchema.index({ riotMatchId: 1 }, { sparse: true });
TournamentCodeSchema.index(
{ riotMatchId: 1 },
{
unique: true,
partialFilterExpression: { riotMatchId: { $type: 'string' } },
},
);
const MatchParticipantSubSchema = new Schema<MatchParticipant>(
{