Skip to content

Commit

Permalink
chore(be): rename files and add fields on contest-submission-summary-…
Browse files Browse the repository at this point in the history
…for-one
  • Loading branch information
Jaehyeon1020 committed Aug 7, 2024
1 parent f33cfe3 commit d9a9971
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
9 changes: 5 additions & 4 deletions apps/backend/apps/admin/src/contest/contest.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
RequiredIntPipe
} from '@libs/pipe'
import { ContestService } from './contest.service'
import { ContestSubmissionSummary } from './model/contest-submission-information.model'
import { ContestSubmissionSummaryForOne } from './model/contest-submission-summary-for-one.model'
import { ContestWithParticipants } from './model/contest-with-participants.model'
import { CreateContestInput } from './model/contest.input'
import { UpdateContestInput } from './model/contest.input'
Expand Down Expand Up @@ -225,13 +225,14 @@ export class ContestResolver {
}
}

@Query(() => [ContestSubmissionSummary])
async getContestSubmissionSummaries(
// TODO: 특정 User의 특정 Contest에 대한 점수만 요약해 불러오는 함수 필요
@Query(() => [ContestSubmissionSummaryForOne])
async getContestSubmissionSummaryByUserId(
@Args('contestId', { type: () => Int }, IDValidationPipe) contestId: number,
@Args('userId', { type: () => Int }, IDValidationPipe) userId: number
) {
try {
return await this.contestService.getContestSubmissionSummaries(
return await this.contestService.getContestSubmissionSummaryByUserId(
contestId,
userId
)
Expand Down
9 changes: 6 additions & 3 deletions apps/backend/apps/admin/src/contest/contest.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ const submissionsWithProblemTitleAndUsername = {
title: 'submission'
},
user: {
username: 'user01'
username: 'user01',
studentId: '1234567890'
}
}

Expand Down Expand Up @@ -366,14 +367,16 @@ describe('ContestService', () => {
})
})

describe('getContestSubmissionSummaries', () => {
describe('getContestSubmissionSummaryByUserId', () => {
it('should return contest submission summaries', async () => {
const res = await service.getContestSubmissionSummaries(1, 1)
const res = await service.getContestSubmissionSummaryByUserId(1, 1)

expect(res).to.deep.equal([
{
contestId: 1,
problemTitle: 'submission',
username: 'user01',
studentId: '1234567890',
submissionResult: 'ACCEPTED',
language: 'C',
submissionTime: '2000-01-01',
Expand Down
7 changes: 5 additions & 2 deletions apps/backend/apps/admin/src/contest/contest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export class ContestService {
return contestProblems
}

async getContestSubmissionSummaries(contestId: number, userId: number) {
async getContestSubmissionSummaryByUserId(contestId: number, userId: number) {
const submissions = await this.prisma.submission.findMany({
where: {
userId,
Expand All @@ -386,7 +386,8 @@ export class ContestService {
},
user: {
select: {
username: true
username: true,
studentId: true
}
}
}
Expand All @@ -397,6 +398,8 @@ export class ContestService {
return {
contestId: submission.contestId,
problemTitle: submission.problem.title,
username: submission.user?.username,
studentId: submission.user?.studentId,
submissionResult: submission.result,
language: submission.language,
submissionTime: submission.createTime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ import { Language, ResultStatus } from '@admin/@generated'
/**
* 특정 User의 특정 Contest에 대한 Submission 정보 (!== model SubmissionResult)
*/
@ObjectType({ description: 'contestSubmissionSummary' })
export class ContestSubmissionSummary {
@ObjectType({ description: 'ContestSubmissionSummaryForOne' })
export class ContestSubmissionSummaryForOne {
@Field(() => Int, { nullable: false })
contestId: number

@Field(() => String, { nullable: false })
problemTitle: string

@Field(() => String, { nullable: false })
username: string

@Field(() => String, { nullable: false })
studentId: string

@Field(() => ResultStatus, { nullable: false })
submissionResult: ResultStatus // Accepted, RuntimeError, ...

Expand Down

0 comments on commit d9a9971

Please sign in to comment.