-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/skkuding/codedang into t702…
…-replace-icons
- Loading branch information
Showing
39 changed files
with
370 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
apps/backend/apps/admin/src/submission/model/contest-submission.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Field, Int, ObjectType } from '@nestjs/graphql' | ||
import { Language, ResultStatus } from '@admin/@generated' | ||
|
||
@ObjectType({ description: 'contestSubmissionOverall' }) | ||
export class ContestSubmission { | ||
@Field(() => String, { nullable: false }) | ||
title!: string // 문제 title | ||
|
||
@Field(() => String, { nullable: false }) | ||
studentId!: string // 학번 | ||
|
||
@Field(() => String, { nullable: true }) | ||
realname?: string // 실명 | ||
|
||
@Field(() => String, { nullable: false }) | ||
username!: string | ||
|
||
@Field(() => ResultStatus, { nullable: false }) | ||
result!: ResultStatus // Accepted, WrongAnswer ... | ||
|
||
@Field(() => Language, { nullable: false }) | ||
language!: Language | ||
|
||
@Field(() => String, { nullable: false }) | ||
submissionTime!: Date // 제출 시각 | ||
|
||
@Field(() => Int, { nullable: true }) | ||
codeSize: number | null | ||
|
||
@Field(() => String, { nullable: true }) | ||
ip: string | null | ||
} |
10 changes: 10 additions & 0 deletions
10
apps/backend/apps/admin/src/submission/model/get-contest-submission.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Field, InputType, Int } from '@nestjs/graphql' | ||
|
||
@InputType() | ||
export class GetContestSubmissionsInput { | ||
@Field(() => Int, { nullable: false }) | ||
contestId!: number | ||
|
||
@Field(() => Int, { nullable: true }) | ||
problemId?: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common' | ||
import { SubmissionResolver } from './submission.resolver' | ||
import { SubmissionService } from './submission.service' | ||
|
||
@Module({ | ||
providers: [SubmissionResolver, SubmissionService] | ||
}) | ||
export class SubmissionModule {} |
37 changes: 37 additions & 0 deletions
37
apps/backend/apps/admin/src/submission/submission.resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { InternalServerErrorException, Logger } from '@nestjs/common' | ||
import { Args, Int, Query, Resolver } from '@nestjs/graphql' | ||
import { CursorValidationPipe } from '@libs/pipe' | ||
import { Submission } from '@admin/@generated' | ||
import { ContestSubmission } from './model/contest-submission.model' | ||
import { GetContestSubmissionsInput } from './model/get-contest-submission.input' | ||
import { SubmissionService } from './submission.service' | ||
|
||
@Resolver(() => Submission) | ||
export class SubmissionResolver { | ||
private readonly logger = new Logger(SubmissionResolver.name) | ||
constructor(private readonly submissionService: SubmissionService) {} | ||
|
||
@Query(() => [ContestSubmission]) | ||
async getContestSubmissions( | ||
@Args('input', { | ||
nullable: false, | ||
type: () => GetContestSubmissionsInput | ||
}) | ||
input: GetContestSubmissionsInput, | ||
@Args('cursor', { nullable: true, type: () => Int }, CursorValidationPipe) | ||
cursor: number | null, | ||
@Args('take', { nullable: true, defaultValue: 10, type: () => Int }) | ||
take: number | ||
): Promise<ContestSubmission[]> { | ||
try { | ||
return await this.submissionService.getContestSubmissions( | ||
input, | ||
take, | ||
cursor | ||
) | ||
} catch (error) { | ||
this.logger.error(error.error) | ||
throw new InternalServerErrorException() | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
apps/backend/apps/admin/src/submission/submission.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Injectable } from '@nestjs/common' | ||
import { PrismaService } from '@libs/prisma' | ||
import type { Language, ResultStatus } from '@admin/@generated' | ||
import type { GetContestSubmissionsInput } from './model/get-contest-submission.input' | ||
|
||
@Injectable() | ||
export class SubmissionService { | ||
constructor(private readonly prisma: PrismaService) {} | ||
|
||
async getContestSubmissions( | ||
input: GetContestSubmissionsInput, | ||
take: number, | ||
cursor: number | null | ||
) { | ||
const paginator = this.prisma.getPaginator(cursor) | ||
|
||
const { contestId, problemId } = input | ||
const contestSubmissions = await this.prisma.submission.findMany({ | ||
...paginator, | ||
take, | ||
where: { | ||
contestId, | ||
problemId | ||
}, | ||
include: { | ||
user: { | ||
select: { | ||
id: true, | ||
username: true, | ||
studentId: true, | ||
userProfile: { | ||
select: { | ||
realName: true | ||
} | ||
} | ||
} | ||
}, | ||
problem: { | ||
select: { | ||
title: true | ||
} | ||
} | ||
} | ||
}) | ||
|
||
const results = contestSubmissions.map((c) => { | ||
return { | ||
title: c.problem.title, | ||
studentId: c.user?.studentId ?? 'Unknown', | ||
realname: c.user?.userProfile?.realName ?? 'Unknown', | ||
username: c.user?.username ?? 'Unknown', | ||
result: c.result as ResultStatus, | ||
language: c.language as Language, | ||
submissionTime: c.createTime, | ||
codeSize: c.codeSize ?? null, | ||
ip: c.userIp ?? 'Unknown' | ||
} | ||
}) | ||
|
||
return results | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...isma/migrations/20240819125317_add_segmentation_fault_on_result_status_enum/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterEnum | ||
ALTER TYPE "ResultStatus" ADD VALUE 'SegmentationFaultError'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.