fix: resume tournament result polling after delayed codes
This commit is contained in:
1 parent
e50a683336
commit
2984bd1604
8 files changed
+207
-21
No files matched your search
@@ -430,6 +430,13 @@ export class TournamentCodeService {
|
||||
public async attachPendingMatches(
|
||||
communityId?: mongoose.Types.ObjectId,
|
||||
): Promise<number> {
|
||||
const matches = await this.attachPendingMatchDocuments(communityId);
|
||||
return matches.length;
|
||||
}
|
||||
|
||||
public async attachPendingMatchDocuments(
|
||||
communityId?: mongoose.Types.ObjectId,
|
||||
): Promise<MatchDocument[]> {
|
||||
const MatchModel = await this.connectionService.getModel('match');
|
||||
const filter: {
|
||||
status: { $in: string[] };
|
||||
@@ -440,15 +447,18 @@ export class TournamentCodeService {
|
||||
if (communityId) filter.communityId = communityId;
|
||||
|
||||
const matches = await MatchModel.find(filter).exec();
|
||||
let touched = 0;
|
||||
const touched: MatchDocument[] = [];
|
||||
for (const match of matches) {
|
||||
if ((match.tournamentCodeIds?.length ?? 0) >= this.resolveRequiredSlots(match)) {
|
||||
if (
|
||||
(match.tournamentCodeIds?.length ?? 0) >=
|
||||
this.resolveRequiredSlots(match)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const before = match.tournamentCodeIds?.length ?? 0;
|
||||
await this.reserveForMatch(match);
|
||||
const after = match.tournamentCodeIds?.length ?? 0;
|
||||
if (after > before) touched += 1;
|
||||
const updatedMatch = await this.reserveForMatch(match);
|
||||
const after = updatedMatch.tournamentCodeIds?.length ?? 0;
|
||||
if (after > before) touched.push(updatedMatch);
|
||||
}
|
||||
return touched;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user