feat: add limited round-robin scheduling

This commit is contained in:
dahyeon committed 2026-06-19 01:13:50 -07:00
1 parent 24983aeb09
commit 658592973e
15 files changed
+403 -63

No files matched your search

@@ -101,6 +101,11 @@ export class CreateMatchDto {
@IsEnum(MATCH_GAME_MODES)
gameMode?: MatchGameMode;
@IsOptional()
@IsInt()
@Min(1)
roundRobinMaxRounds?: number;
@IsOptional()
@IsArray()
@IsString({ each: true })
@@ -156,6 +161,11 @@ export class UpdateMatchDto {
@IsEnum(MATCH_GAME_MODES)
gameMode?: MatchGameMode;
@IsOptional()
@IsInt()
@Min(1)
roundRobinMaxRounds?: number;
@IsOptional()
@IsArray()
@IsString({ each: true })
@@ -57,6 +57,7 @@ export class MatchController {
maxParticipants: body.maxParticipants ?? 10,
gameCount: body.gameCount,
gameMode: body.gameMode ?? 'pair',
roundRobinMaxRounds: body.roundRobinMaxRounds,
prizes: body.prizes ?? [],
notices: body.notices ?? [],
schedule: body.schedule ?? [],
@@ -292,6 +292,29 @@ describe('MatchService', () => {
expect(matchStatsService.removeByMatch).toHaveBeenCalledWith(match._id);
});
it('rejects round-robin max round changes after recruiting', async () => {
const communityId = new mongoose.Types.ObjectId();
const match = {
communityId,
status: 'team-built',
tournamentCodeIds: [],
set: jest.fn(),
save: jest.fn().mockResolvedValue(undefined),
};
const { service } = createService(match);
await expect(
service.update({
matchId: new mongoose.Types.ObjectId(),
communityId,
patch: { roundRobinMaxRounds: 3 },
}),
).rejects.toThrow(
'maxParticipants, gameMode, and roundRobinMaxRounds can only be changed while recruiting.',
);
expect(match.set).not.toHaveBeenCalled();
});
it('releases reserved codes when returning a built match to recruiting', async () => {
const communityId = new mongoose.Types.ObjectId();
const codeId = new mongoose.Types.ObjectId();
+4 -2
View File
@@ -214,10 +214,12 @@ export class MatchService {
const previousStatus = match.status;
if (
previousStatus !== 'recruiting' &&
('maxParticipants' in params.patch || 'gameMode' in params.patch)
('maxParticipants' in params.patch ||
'gameMode' in params.patch ||
'roundRobinMaxRounds' in params.patch)
) {
throw new BadRequestException(
'maxParticipants and gameMode can only be changed while recruiting.',
'maxParticipants, gameMode, and roundRobinMaxRounds can only be changed while recruiting.',
);
}
match.set(params.patch);