diff --git a/apps/backend/apps/admin/src/contest/contest.resolver.ts b/apps/backend/apps/admin/src/contest/contest.resolver.ts index a0d549cfd2..c749795e55 100644 --- a/apps/backend/apps/admin/src/contest/contest.resolver.ts +++ b/apps/backend/apps/admin/src/contest/contest.resolver.ts @@ -304,15 +304,21 @@ export class ContestResolver { */ @Query(() => [UserContestScoreSummaryWithUserInfo]) async getContestScoreSummaries( - @Args('take', { type: () => Int, defaultValue: 10 }) take: number, - @Args('contestId', { type: () => Int }) contestId: number, - @Args('cursor', { type: () => Int, nullable: true }) cursor: number | null + @Args('contestId', { type: () => Int, nullable: false }, IDValidationPipe) + contestId: number, + @Args('take', { type: () => Int, defaultValue: 10 }) + take: number, + @Args('cursor', { type: () => Int, nullable: true }, CursorValidationPipe) + cursor: number | null, + @Args('searchingName', { type: () => String, nullable: true }) + searchingName?: string ) { try { return await this.contestService.getContestScoreSummaries( - take, contestId, - cursor + take, + cursor, + searchingName ) } catch (error) { if (error instanceof EntityNotExistException) { diff --git a/apps/backend/apps/admin/src/contest/contest.service.ts b/apps/backend/apps/admin/src/contest/contest.service.ts index 900585bd7a..3ba76eeb14 100644 --- a/apps/backend/apps/admin/src/contest/contest.service.ts +++ b/apps/backend/apps/admin/src/contest/contest.service.ts @@ -766,17 +766,24 @@ export class ContestService { const problemId = submission.problemId if (problemId in latestSubmissions) continue - const maxScore = ( - await this.prisma.contestProblem.findUniqueOrThrow({ - where: { - // eslint-disable-next-line @typescript-eslint/naming-convention - contestId_problemId: { - contestId: submission.contestId!, - problemId: submission.problemId - } + const contestProblem = await this.prisma.contestProblem.findUnique({ + where: { + // eslint-disable-next-line @typescript-eslint/naming-convention + contestId_problemId: { + contestId: submission.contestId!, + problemId: submission.problemId } - }) - ).score + }, + select: { + score: true + } + }) + + if (!contestProblem) { + throw new EntityNotExistException('contestProblem') + } + + const maxScore = contestProblem.score latestSubmissions[problemId] = { result: submission.result as ResultStatus, @@ -789,9 +796,10 @@ export class ContestService { } async getContestScoreSummaries( - take: number, contestId: number, - cursor: number | null + take: number, + cursor: number | null, + searchingName?: string ) { const paginator = this.prisma.getPaginator(cursor) @@ -801,7 +809,17 @@ export class ContestService { contestId, userId: { not: null - } + }, + user: searchingName + ? { + userProfile: { + realName: { + contains: searchingName, + mode: 'insensitive' + } + } + } + : undefined }, take, include: { diff --git a/apps/backend/apps/admin/src/submission/model/get-contest-submission.input.ts b/apps/backend/apps/admin/src/submission/model/get-contest-submission.input.ts index 7f6a8f9b9f..645266a8eb 100644 --- a/apps/backend/apps/admin/src/submission/model/get-contest-submission.input.ts +++ b/apps/backend/apps/admin/src/submission/model/get-contest-submission.input.ts @@ -7,4 +7,7 @@ export class GetContestSubmissionsInput { @Field(() => Int, { nullable: true }) problemId?: number + + @Field(() => String, { nullable: true }) + searchingName?: string } diff --git a/apps/backend/apps/admin/src/submission/submission.service.ts b/apps/backend/apps/admin/src/submission/submission.service.ts index 89170b9f29..90e1f8e6de 100644 --- a/apps/backend/apps/admin/src/submission/submission.service.ts +++ b/apps/backend/apps/admin/src/submission/submission.service.ts @@ -17,13 +17,23 @@ export class SubmissionService { ) { const paginator = this.prisma.getPaginator(cursor) - const { contestId, problemId } = input + const { contestId, problemId, searchingName } = input const contestSubmissions = await this.prisma.submission.findMany({ ...paginator, take, where: { contestId, - problemId + problemId, + user: searchingName + ? { + userProfile: { + realName: { + contains: searchingName, + mode: 'insensitive' + } + } + } + : undefined }, include: { user: { @@ -44,7 +54,7 @@ export class SubmissionService { contestProblem: { where: { contestId, - problemId: problemId ?? undefined + problemId } } } diff --git a/collection/admin/Contest/Get Contest Score Summaries/Succeed.bru b/collection/admin/Contest/Get Contest Score Summaries/Succeed.bru index e515c04222..f3d1a08e0c 100644 --- a/collection/admin/Contest/Get Contest Score Summaries/Succeed.bru +++ b/collection/admin/Contest/Get Contest Score Summaries/Succeed.bru @@ -33,8 +33,8 @@ body:graphql { body:graphql:vars { { "contestId": 1, - "userId": 4 - // "problemId": 1 + "userId": 1 + // "searchingName": "lee" } } @@ -44,4 +44,9 @@ docs { * Contest에 참여한 User와, 점수 요약을 함께 불러옵니다. * Contest Overall 페이지의 Participants 탭의 정보 * https://github.com/skkuding/codedang/pull/2029 + + #### 필요 인자 + | `contestId` | `searchingName?` | `take?` | `cursor?` | + |----------|--------|----------|------------| + | 불러올 Contest의 id | 필터링할 User의 realName(없으면 모든 유저) | Pagination 구현을 위함(default: 10) | Pagination 구현을 위함(default: null) | } diff --git a/collection/admin/Submission/Get Contest Submissions/Succeed.bru b/collection/admin/Submission/Get Contest Submissions/Succeed.bru index 3d4db915fe..d7f3942608 100644 --- a/collection/admin/Submission/Get Contest Submissions/Succeed.bru +++ b/collection/admin/Submission/Get Contest Submissions/Succeed.bru @@ -40,7 +40,9 @@ body:graphql { body:graphql:vars { { "input": { - "contestId": 1 + "contestId": 1, + "problemId": 1, + "searchingName": "lee" }, "take": 10 } @@ -53,7 +55,13 @@ docs { - https://github.com/skkuding/codedang/pull/1924 #### 필요 인자 - |`input`|`take`|`cursor`| - |----------|----------|----------| - | `contestId`: 제출 내역을 불러올 Contest의 ID입니다. `problemId?`: 제출된 내역 중 특정 Problem의 제출만을 필터링 할 수 있습니다.| pagination 구현을 위함 | pagination 구현을 위함 | + | `input` | `take` | `cursor` | + |----------|--------|----------| + | 밑에서 설명 | Pagination 구현을 위함 | Pagination 구현을 위함 | + + `input` + - `contestId`: 제출 내역을 불러올 Contest의 ID + - `problemId?`: 제출된 내역 중 특정 Problem의 제출만 필터링 + - `searchingName?`: 필터링할 User의 realName(없으면 모든 유저) + }