From 3179115f0cfe2efc082613704b881018a58c32da Mon Sep 17 00:00:00 2001 From: Jaehyeon Kim Date: Mon, 15 Apr 2024 22:57:02 +0900 Subject: [PATCH] fix(be): make admin to get all contest submissions (#1651) --- .../apps/client/src/submission/submission.controller.ts | 1 + .../client/src/submission/submission.service.spec.ts | 9 ++++++--- .../apps/client/src/submission/submission.service.ts | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/backend/apps/client/src/submission/submission.controller.ts b/apps/backend/apps/client/src/submission/submission.controller.ts index 9e42f3a6f5..ec3a945ce1 100644 --- a/apps/backend/apps/client/src/submission/submission.controller.ts +++ b/apps/backend/apps/client/src/submission/submission.controller.ts @@ -172,6 +172,7 @@ export class ContestSubmissionController { problemId, contestId, userId: req.user.id, + isAdmin: req.user.isAdmin(), groupId }) } catch (error) { diff --git a/apps/backend/apps/client/src/submission/submission.service.spec.ts b/apps/backend/apps/client/src/submission/submission.service.spec.ts index 68800869d9..5c6a97da81 100644 --- a/apps/backend/apps/client/src/submission/submission.service.spec.ts +++ b/apps/backend/apps/client/src/submission/submission.service.spec.ts @@ -422,7 +422,8 @@ describe('SubmissionService', () => { await service.getContestSubmissions({ problemId: problems[0].id, contestId: 1, - userId: submissions[0].userId + userId: submissions[0].userId, + isAdmin: false }) ) }) @@ -436,7 +437,8 @@ describe('SubmissionService', () => { service.getContestSubmissions({ problemId: problems[0].id, contestId: 1, - userId: submissions[0].userId + userId: submissions[0].userId, + isAdmin: false }) ).to.be.rejectedWith(NotFoundException) }) @@ -451,7 +453,8 @@ describe('SubmissionService', () => { service.getContestSubmissions({ problemId: problems[0].id, contestId: 1, - userId: submissions[0].userId + userId: submissions[0].userId, + isAdmin: false }) ).to.be.rejectedWith(NotFoundException) }) diff --git a/apps/backend/apps/client/src/submission/submission.service.ts b/apps/backend/apps/client/src/submission/submission.service.ts index 9be3b3b8da..c241fabc8f 100644 --- a/apps/backend/apps/client/src/submission/submission.service.ts +++ b/apps/backend/apps/client/src/submission/submission.service.ts @@ -628,6 +628,7 @@ export class SubmissionService implements OnModuleInit { problemId, contestId, userId, + isAdmin, groupId = OPEN_SPACE_ID, cursor = null, take = 10 @@ -635,6 +636,7 @@ export class SubmissionService implements OnModuleInit { problemId: number contestId: number userId: number + isAdmin: boolean groupId?: number cursor?: number | null take?: number @@ -666,7 +668,7 @@ export class SubmissionService implements OnModuleInit { where: { problemId, contestId, - userId + userId: isAdmin ? undefined : userId // Admin 계정인 경우 자신이 생성한 submission이 아니더라도 조회가 가능 }, select: { id: true,