Skip to content

Commit

Permalink
fix(be): make admin to get all contest submissions (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaehyeon1020 authored Apr 15, 2024
1 parent ece6da8 commit 3179115
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export class ContestSubmissionController {
problemId,
contestId,
userId: req.user.id,
isAdmin: req.user.isAdmin(),
groupId
})
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
)
})
Expand All @@ -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)
})
Expand All @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,15 @@ export class SubmissionService implements OnModuleInit {
problemId,
contestId,
userId,
isAdmin,
groupId = OPEN_SPACE_ID,
cursor = null,
take = 10
}: {
problemId: number
contestId: number
userId: number
isAdmin: boolean
groupId?: number
cursor?: number | null
take?: number
Expand Down Expand Up @@ -666,7 +668,7 @@ export class SubmissionService implements OnModuleInit {
where: {
problemId,
contestId,
userId
userId: isAdmin ? undefined : userId // Admin 계정인 경우 자신이 생성한 submission이 아니더라도 조회가 가능
},
select: {
id: true,
Expand Down

0 comments on commit 3179115

Please sign in to comment.