feat: auto provision tournament codes

This commit is contained in:
dahyeon committed 2026-06-20 02:29:30 -07:00
1 parent 65bc214fb2
commit bac29ac933
13 files changed
+1164 -117

No files matched your search

@@ -37,7 +37,7 @@ export class TournamentCodeService {
constructor(private readonly connectionService: ConnectionService) {}
public async bulkUpload(params: {
communityId: mongoose.Types.ObjectId;
communityId?: mongoose.Types.ObjectId;
uploadedBy: mongoose.Types.ObjectId;
codes: TournamentCodeUploadItem[];
}): Promise<BulkUploadTournamentCodesResponse> {
@@ -121,6 +121,17 @@ export class TournamentCodeService {
};
}
public async countUsableAvailable(): Promise<number> {
const TournamentCodeModel =
await this.connectionService.getModel('tournamentCode');
return TournamentCodeModel.countDocuments({
state: 'available',
expiresAt: {
$gt: new Date(Date.now() + TOURNAMENT_CODE_EXPIRY_MARGIN_MS),
},
}).exec();
}
public async list(params: {
state?: TournamentCodeState;
limit?: number;
@@ -492,7 +503,7 @@ export class TournamentCodeService {
}
private normalizeCode(code: string | undefined): string {
return (code ?? '').trim().toUpperCase();
return (code ?? '').trim();
}
private replaceTournamentCodeId(