Skip to content

Commit

Permalink
Merge branch 'main' into 1047-implement-admin-announcement-module
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee-won-hyeok authored Feb 19, 2024
2 parents 2c4a950 + c4f227a commit 7549e51
Show file tree
Hide file tree
Showing 175 changed files with 5,447 additions and 3,518 deletions.
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"customizations": {
"vscode": {
"extensions": [
"apollographql.vscode-apollo",
"bradlc.vscode-tailwindcss",
"bruno-api-client.bruno",
"csstools.postcss",
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ inputs:
runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v3
with:
version: latest
- uses: actions/setup-node@v4
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
file: ./backend/Dockerfile
push: true
build-args: 'target=client'
tags: ${{ steps.login-ecr.outputs.registry }}/codedang-admin-api:latest
tags: ${{ steps.login-ecr.outputs.registry }}/codedang-client-api:latest

build-admin-api:
name: Build admin-api image
Expand Down Expand Up @@ -102,16 +102,19 @@ jobs:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY }}
aws-region: ${{ env.AWS_REGION }}

- name: Trigger Amplify Frontend Build
run: curl -X POST -d {} "${{ secrets.AMPLIFY_WEBHOOK }}"

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.5.2

- name: Create Terraform variable file
working-directory: ./infra/deploy
run: |
echo $TFVARS >> terraform.tfvars
echo $OAUTH_GITHUB >> terraform.tfvars
echo $OAUTH_KAKAO >> terraform.tfvars
echo "$TFVARS" >> terraform.tfvars
echo "$OAUTH_GITHUB" >> terraform.tfvars
echo "$OAUTH_KAKAO" >> terraform.tfvars
env:
TFVARS: ${{ secrets.TFVARS }}
OAUTH_GITHUB: ${{ secrets.OAUTH_GITHUB }}
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/documentation.yml

This file was deleted.

3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ dist/
# pnpm store
.pnpm-store

# Vitepress
docs/.vitepress/cache/

# NestJS & GraphQL
@generated/
backend/schema.gql
Expand Down
1 change: 1 addition & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ github:

vscode:
extensions:
- apollographql.vscode-apollo
- bradlc.vscode-tailwindcss
- bruno-api-client.bruno
- csstools.postcss
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
pnpm-lock.yaml
.pnpm-store/
@generated/
__generated__/
schema.gql
collection/
.next/
Expand Down
10 changes: 9 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"recommendations": ["ms-vscode-remote.remote-containers"]
// Recommendations for Frontend team, developing without devcontainer
"recommendations": [
"apollographql.vscode-apollo",
"dbaeumer.vscode-eslint",
"donjayamanne.githistory",
"eamodio.gitlens",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode"
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Codedang은 스꾸딩(skkuding) 팀에서 만들고 관리하는 성균관대학

문서 웹페이지를 참고해주세요. https://docs.codedang.com

문서 미리보기는 `pnpm docs:dev` 명령어로 가능합니다.
> 문서 저장소: [skkuding/docs](https://github.com/skkuding/docs)
## Contributing Guide 👏

Expand Down
10 changes: 10 additions & 0 deletions apollo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
client: {
includes: ['./frontend-client/**/*.ts', './frontend-client/**/*.tsx'],
excludes: ['**/__generated__/**'],
service: {
name: 'codedang-graphql-app',
url: 'https://dev.codedang.com/graphql'
}
}
}
10 changes: 7 additions & 3 deletions backend/apps/admin/src/contest/contest.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,15 @@ const problem: Problem = {
exposeTime: faker.date.past(),
createTime: faker.date.past(),
updateTime: faker.date.past(),
inputExamples: ['input'],
outputExamples: ['input'],
samples: [],
submissionCount: 0,
acceptedCount: 0,
acceptedRate: 0
acceptedRate: 0,
engDescription: null,
engHint: null,
engInputDescription: null,
engOutputDescription: null,
engTitle: null
}

const contestProblem: ContestProblem = {
Expand Down
40 changes: 28 additions & 12 deletions backend/apps/admin/src/problem/mock/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ export const problems: Problem[] = [
createTime: faker.date.past(),
updateTime: faker.date.past(),
exposeTime: faker.date.anytime(),
inputExamples: [],
outputExamples: [],
isVisible: true
samples: [],
isVisible: true,
engTitle: null,
engDescription: null,
engHint: null,
engInputDescription: null,
engOutputDescription: null
},
{
id: 2,
Expand All @@ -66,9 +70,13 @@ export const problems: Problem[] = [
createTime: faker.date.past(),
updateTime: faker.date.past(),
exposeTime: faker.date.anytime(),
inputExamples: [],
outputExamples: [],
isVisible: true
samples: [],
isVisible: true,
engTitle: null,
engDescription: null,
engHint: null,
engInputDescription: null,
engOutputDescription: null
}
]

Expand Down Expand Up @@ -120,9 +128,13 @@ export const importedProblems: Problem[] = [
createTime: faker.date.past(),
updateTime: faker.date.past(),
exposeTime: faker.date.anytime(),
inputExamples: [],
outputExamples: [],
isVisible: true
samples: [],
isVisible: true,
engTitle: null,
engDescription: null,
engHint: null,
engInputDescription: null,
engOutputDescription: null
},
{
id: 33,
Expand Down Expand Up @@ -161,8 +173,12 @@ export const importedProblems: Problem[] = [
createTime: faker.date.past(),
updateTime: faker.date.past(),
exposeTime: faker.date.anytime(),
inputExamples: [],
outputExamples: [],
isVisible: true
samples: [],
isVisible: true,
engTitle: null,
engDescription: null,
engHint: null,
engInputDescription: null,
engOutputDescription: null
}
]
27 changes: 14 additions & 13 deletions backend/apps/admin/src/problem/model/problem.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { GraphQLUpload } from 'graphql-upload'
import { Language, Level } from '@admin/@generated'
import type { FileUploadDto } from '../dto/file-upload.dto'
import { Template } from './template.input'
import { Testcase } from './testcase.input'
import { Testcase, Sample } from './testcase.input'

@InputType()
export class CreateProblemInput {
Expand Down Expand Up @@ -44,11 +44,8 @@ export class CreateProblemInput {
@Field(() => String, { nullable: false })
source!: string

@Field(() => [String], { nullable: false })
inputExamples!: Array<string>

@Field(() => [String], { nullable: false })
outputExamples!: Array<string>
@Field(() => [Sample], { nullable: false })
samples!: Array<Sample>

@Field(() => [Testcase], { nullable: false })
testcases!: Array<Testcase>
Expand Down Expand Up @@ -76,8 +73,7 @@ export interface UploadProblemInput {
memoryLimit: number
difficulty: keyof typeof Level
source: string
inputExamples: Array<string>
outputExamples: Array<string>
samples: Array<Sample>
}

@InputType()
Expand All @@ -97,6 +93,14 @@ export class UpdateProblemTagInput {
@Field(() => [Int], { nullable: false })
delete!: Array<number>
}
@InputType()
export class UpdateSamples {
@Field(() => [Sample], { nullable: false })
create!: Array<Sample>

@Field(() => [Int], { nullable: false })
delete!: Array<number>
}

@InputType()
export class UpdateProblemInput {
Expand Down Expand Up @@ -139,11 +143,8 @@ export class UpdateProblemInput {
@Field(() => String, { nullable: true })
source?: string

@Field(() => [String], { nullable: true })
inputExamples?: Array<string>

@Field(() => [String], { nullable: true })
outputExamples?: Array<string>
@Field(() => UpdateSamples, { nullable: true })
samples?: UpdateSamples

@Field(() => [Testcase], { nullable: true })
testcases?: Array<Testcase & { id: number }>
Expand Down
5 changes: 4 additions & 1 deletion backend/apps/admin/src/problem/model/testcase.input.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { Field, InputType, Int } from '@nestjs/graphql'

@InputType()
export class Testcase {
export class Sample {
@Field(() => String, { nullable: false })
input!: string

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

@InputType()
export class Testcase extends Sample {
@Field(() => Int, { nullable: true })
scoreWeight?: number
}
38 changes: 38 additions & 0 deletions backend/apps/admin/src/problem/problem-tag.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { InternalServerErrorException, Logger } from '@nestjs/common'
import { Query, Resolver, ResolveField, Parent } from '@nestjs/graphql'
import { ProblemTag, Tag } from '@generated'
import { ProblemService } from './problem.service'

@Resolver(() => ProblemTag)
export class ProblemTagResolver {
private readonly logger = new Logger(ProblemTagResolver.name)

constructor(private readonly problemService: ProblemService) {}

@ResolveField('tag', () => Tag)
async getTag(@Parent() problemTag: ProblemTag) {
try {
return await this.problemService.getTag(problemTag.tagId)
} catch (error) {
this.logger.error(error)
throw new InternalServerErrorException()
}
}
}

@Resolver(() => Tag)
export class TagResolver {
private readonly logger = new Logger(TagResolver.name)

constructor(private readonly problemService: ProblemService) {}

@Query(() => [Tag])
async getTags() {
try {
return await this.problemService.getTags()
} catch (error) {
this.logger.error(error)
throw new InternalServerErrorException()
}
}
}
3 changes: 2 additions & 1 deletion backend/apps/admin/src/problem/problem.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Module } from '@nestjs/common'
import { StorageModule } from '@admin/storage/storage.module'
import { ProblemTagResolver, TagResolver } from './problem-tag.resolver'
import { ProblemResolver } from './problem.resolver'
import { ProblemService } from './problem.service'

@Module({
imports: [StorageModule],
providers: [ProblemResolver, ProblemService]
providers: [ProblemResolver, ProblemTagResolver, TagResolver, ProblemService]
})
export class ProblemModule {}
22 changes: 18 additions & 4 deletions backend/apps/admin/src/problem/problem.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
UsePipes,
ValidationPipe
} from '@nestjs/common'
import { Args, Context, Query, Int, Mutation, Resolver } from '@nestjs/graphql'
import { Prisma } from '@prisma/client'
import { AuthenticatedRequest } from '@libs/auth'
import { OPEN_SPACE_ID } from '@libs/constants'
Expand Down Expand Up @@ -308,8 +307,23 @@ export class ProblemResolver {
}
}

@Query(() => [Tag])
async getTags() {
return await this.problemService.getTags()
@ResolveField('problemTag', () => [ProblemTag])
async getProblemTags(@Parent() problem: Problem) {
try {
return await this.problemService.getProblemTags(problem.id)
} catch (error) {
this.logger.error(error)
throw new InternalServerErrorException()
}
}

@ResolveField('problemTestcase', () => [ProblemTestcase])
async getProblemTestCases(@Parent() problem: Problem) {
try {
return await this.problemService.getProblemTestcases(problem.id)
} catch (error) {
this.logger.error(error)
throw new InternalServerErrorException()
}
}
}
Loading

0 comments on commit 7549e51

Please sign in to comment.