Skip to content

Commit

Permalink
Merge branch 'develop' into hotfix/scoreboard-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
glowisn authored Dec 12, 2023
2 parents 66ede66 + 870c2ec commit e3e50b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 9 additions & 4 deletions server/src/problem/problem.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ export class ProblemService {
}

async getProblemsByBojProblemIds(bojProblemIds: number[]) {
return await this.problemRepository
.createQueryBuilder('problem')
.where('problem.bojProblemId IN (:...bojProblemIds)', { bojProblemIds })
.getMany();
const problemEntities: Problem[] = [];
for (const bojProblemId of bojProblemIds) {
const problem = await this.getProblemByBojProblemId(bojProblemId);
if (problem == null) {
throw new Error(`bojProblemId ${bojProblemId} not found`);
}
problemEntities.push(problem);
}
return problemEntities;
}
}
10 changes: 6 additions & 4 deletions server/src/socket/socket.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,17 @@ export class SocketService {
throw new WsException('방장이 아닙니다.');
}

this.logger.debug(util.inspect(startingRoomInfo));

// update room entity properties: problems, isStarted, endAt

const { problems, duration, isStarted } = startingRoomInfo;
const { problems, duration } = startingRoomInfo;
if (problems == null) throw new WsException('problems is null');
if (isStarted == null) throw new WsException('isStarted is null');
if (duration == null) throw new WsException('duration is null');
const bojProblemIds = problems.map((problem) => problem.bojProblemId);
room.problems =
this.problemService.getProblemsByBojProblemIds(bojProblemIds);
const problemEntities =
await this.problemService.getProblemsByBojProblemIds(bojProblemIds);
room.problems = Promise.resolve(problemEntities);

room.isStarted = true;
room.endAt = new Date(Date.now() + duration * 60 * 1000);
Expand Down

0 comments on commit e3e50b6

Please sign in to comment.