Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(be): add client get submission order option #1692

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
8fc8620
feat(be): add finding max cpu, memory and sorting with order option
mnseok May 13, 2024
986e102
fix(be): add order in query
mnseok May 13, 2024
0890900
fix(be): add submission mock data
mnseok May 13, 2024
8a327c8
fix(be): addd mock user d
mnseok May 13, 2024
11c3740
fix(be): fix mock data
mnseok May 13, 2024
ed4183f
fix(be): add date order option
mnseok May 13, 2024
f8ffbc0
chore(fe): remove duplicated types and arrange by categories (#1687)
dayongkr May 13, 2024
fec1db5
fix(fe): prevent unnecessary rerenders in editor page (#1693)
dayongkr May 16, 2024
723bc43
feat(ci): run ci depending on code change (#1697)
dotoleeoak May 18, 2024
e1139b8
fix(fe): update commandlist (#1698)
youznn May 20, 2024
425f0a3
feat(fe): add vitest for frontend unit testing (#1695)
dayongkr May 20, 2024
053195b
fix(be): add argon2 hash options (#1700)
cho-to May 21, 2024
c6e137e
fix(infra): upgrade instance type of client api (#1701)
ssupecial May 22, 2024
c767573
fix(infra): downgrade instance type of api (#1702)
ssupecial May 22, 2024
c5303cb
chore(be): standardize the return format of 'get' apis (#1507)
Jaehyeon1020 May 23, 2024
cc04294
perf(fe): use dynamic subset of pretendard (#1706)
dotoleeoak May 24, 2024
b60d8cb
chore: add resize attribute to text editor (#1704)
B0XERCAT May 24, 2024
0d30643
fix(infra): fix tf lockfile (#1694)
goo314 May 27, 2024
73fab16
feat(fe): change codes for changed get api return (#1708)
jihorobert May 27, 2024
77f76a1
refactor(fe): refactor graphql query files (#1713)
B0XERCAT May 27, 2024
3b4beaa
fix(deps): update all non-major dependencies (#1690)
renovate[bot] May 27, 2024
b975a06
fix(infra): fix tf lockfile again... (#1719)
goo314 May 27, 2024
e59127c
fix(be): redact password-again (#1723)
Jaehyeon1020 May 28, 2024
1b984b7
feat(fe): persist language and code datas (#1720)
dayongkr May 28, 2024
2e23941
feat(be): implement image upload (#1514)
Jaehyeon1020 May 29, 2024
58c2db5
refactor(infra): create new terraform project to prepare refactoring …
goo314 May 30, 2024
3f725ce
fix(deps): update tiptap monorepo to ^2.4.0 (#1709)
renovate[bot] May 30, 2024
91860a3
chore(deps): update dependency sinon to v18 (#1710)
renovate[bot] May 31, 2024
f5846bc
fix(deps): update dependency @headlessui/react to v2 (#1712)
renovate[bot] May 31, 2024
d9043a4
fix(infra): set aws profile as skkuding (#1728)
goo314 Jun 3, 2024
bbfd6ab
chore(deps): update all non-major dependencies (#1730)
renovate[bot] Jun 4, 2024
6e60cd3
fix(infra): add tag name into aws eip (#1734)
k1g99 Jun 5, 2024
e1a6416
fix(be): inject user role in groud-member-guard (#1744)
Jaehyeon1020 Jul 1, 2024
f80a875
fix(deps): update all non-major dependencies (#1739)
renovate[bot] Jul 2, 2024
6660c2d
chore(deps): update codemirror (#1738)
renovate[bot] Jul 2, 2024
21d091f
chore(deps): update dependency nyc to v17 (#1742)
renovate[bot] Jul 2, 2024
583a127
chore(deps): update dependency @testing-library/react to v16 (#1740)
renovate[bot] Jul 2, 2024
6466e25
feat(fe): add Katex editor (#1752)
youznn Jul 2, 2024
94b666e
fix(deps): update dependency pino-http to v10 (#1733)
renovate[bot] Jul 2, 2024
5f2ee5a
chore(deps): update docker/build-push-action action to v6 (#1746)
renovate[bot] Jul 2, 2024
54982bd
fix(fe): change contest problem interface (#1758)
jihorobert Jul 3, 2024
48b6f27
fix(infra): fix e2e test run bruno collection script (#1762)
jimin9038 Jul 3, 2024
befddb6
feat(fe): implement indent extension (#1759)
youznn Jul 3, 2024
2cb8daa
fix(fe): fix notice stage server error (#1765)
jihorobert Jul 3, 2024
274a6ab
chore(fe): prevent signup modal reset (#1757)
jwoojin9 Jul 3, 2024
2deff1c
fix(fe): handle null user in submission (#1769)
jwoojin9 Jul 3, 2024
2b16680
fix(be): include-template-in-problem-select-option (#1767)
Jaehyeon1020 Jul 3, 2024
be731d2
fix(be): resolve admin problem test error (#1772)
gyunseo Jul 4, 2024
771198f
fix(be): resolve client group unit test error (#1773)
gyunseo Jul 4, 2024
50e0575
feat(be): add finding max cpu, memory and sorting with order option
mnseok May 13, 2024
eb9c863
fix(be): add submission mock data
mnseok May 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"database",
"cache",
"rabbitmq",
"testcase",
"storage",
"test-database"
],
"workspaceFolder": "/workspace",
Expand Down
11 changes: 10 additions & 1 deletion .env.stage
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,26 @@ RABBITMQ_CONSUMER_CONNECTION_NAME=iris-consumer
RABBITMQ_CONSUMER_TAG=consumer
RABBITMQ_PRODUCER_CONNECTION_NAME=iris-producer

# Storage
STORAGE_BUCKET_ENDPOINT_URL=http://127.0.0.1:9000
# Testcase Endpoint
TESTCASE_BUCKET_NAME=test-bucket
TESTCASE_ENDPOINT_URL=http://127.0.0.1:9000
# TESTCASE_ENDPOINT_URL=http://127.0.0.1:9000
TESTCASE_ACCESS_KEY=skku
TESTCASE_SECRET_KEY=skku1234

# Media Upload Endpoint
MEDIA_BUCKET_NAME=image-bucket
# MEDIA_BUCKET_BASE_URL=http://127.0.0.1:9000/image-bucket/
MEDIA_ACCESS_KEY=skku
MEDIA_SECRET_KEY=skku1234

REDIS_HOST=127.0.0.1
REDIS_PORT=6380

DATABASE_URL=postgresql://postgres:[email protected]:5433/skkuding?schema=public
TEST_DATABASE_URL=postgresql://postgres:[email protected]:5434/skkuding?schema=public


# TODO: Add information where each of these variables are used
# TODO: I want to edit values after the container is created...
8 changes: 4 additions & 4 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
file: ./apps/backend/Dockerfile
push: true
Expand All @@ -55,7 +55,7 @@ jobs:
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
file: ./apps/backend/Dockerfile
push: true
Expand All @@ -79,7 +79,7 @@ jobs:
uses: aws-actions/amazon-ecr-login@v2

- name: Build and push image (iris)
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: true
context: '{{defaultContext}}:apps/iris'
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:

- name: Terraform Init
working-directory: ./apps/infra/deploy
run: terraform init -upgrade
run: terraform init

# TODO: plan in the other job, and reuse the plan file
- name: Terraform Plan
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/cd-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
file: ./apps/backend/Dockerfile # build with root context
push: true
Expand All @@ -47,7 +47,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
file: ./apps/backend/Dockerfile # build with root context
push: true
Expand All @@ -69,7 +69,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push iris image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
push: true
context: '{{defaultContext}}:apps/iris'
Expand Down Expand Up @@ -143,8 +143,8 @@ jobs:

- name: Run Bruno Collection (Client)
working-directory: ./collection/client
run: bru run --env stage
run: bru run --env Stage

- name: Run Bruno Collection (Admin)
working-directory: ./collection/admin
run: bru run --env stage
run: bru run --env Stage
93 changes: 79 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,57 +7,108 @@ on:
types: [opened, edited, synchronize, reopened]

jobs:
build:
name: Build
build-backend:
name: Build Backend
runs-on: ubuntu-latest

strategy:
matrix:
target: [frontend, backend, backend-admin]
target: [client, admin]

steps:
- uses: actions/checkout@v4

- name: Check if source code has changed
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
shared: &shared
- 'apps/backend/libs/**'
- 'apps/backend/prisma/**'
- 'apps/backend/*.json'
- 'pnpm-lock.yaml'
client:
- *shared
- 'apps/backend/apps/client/**'
admin:
- *shared
- 'apps/backend/apps/admin/**'

- uses: ./.github/actions/setup-pnpm
if: ${{ steps.filter.outputs[matrix.target] == 'true' }}

- name: Generate Prisma Client
if: ${{ matrix.target == 'backend' || matrix.target == 'backend-admin' }}
if: ${{ steps.filter.outputs[matrix.target] == 'true' }}
run: pnpm --filter="@codedang/backend" exec prisma generate

- name: Build
if: ${{ steps.filter.outputs[matrix.target] == 'true' }}
run: pnpm --filter="@codedang/backend" build ${{ matrix.target }}

build-frontend:
name: Build Frontend
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check if source code has changed
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
frontend:
- 'apps/frontend/**'
- 'pnpm-lock.yaml'

- uses: ./.github/actions/setup-pnpm
if: steps.filter.outputs.frontend == 'true'

- name: Setup Next.js build cache
if: ${{ matrix.target == 'frontend' }}
uses: actions/cache@v4
if: steps.filter.outputs.frontend == 'true'
with:
path: apps/frontend/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('pnpm-lock.yaml') }}-

- name: Load Next.js environment
if: ${{ matrix.target == 'frontend' }}
if: steps.filter.outputs.frontend == 'true'
run: |
echo "NEXT_PUBLIC_BASEURL=https://stage.codedang.com/api" >> apps/frontend/.env
echo "NEXT_PUBLIC_GQL_BASEURL=https://stage.codedang.com/graphql" >> apps/frontend/.env
echo "NEXT_URL=https://stage.codedang.com" >> apps/frontend/.env

- name: Build (backend admin)
if: ${{ matrix.target == 'backend-admin' }}
run: pnpm --filter="@codedang/backend" build admin
- name: Build
if: ${{ matrix.target != 'backend-admin' }}
run: pnpm --filter="apps/${{ matrix.target }}" build
if: steps.filter.outputs.frontend == 'true'
run: pnpm --filter="@codedang/frontend" build

typecheck:
name: Typecheck
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Check if source code has changed
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'apps/backend/**'

- uses: ./.github/actions/setup-pnpm
if: steps.filter.outputs.backend == 'true'

- name: Generate Prisma Client
if: steps.filter.outputs.backend == 'true'
run: pnpm --filter="@codedang/backend" exec prisma generate

- name: Check types (backend) # For spec files
if: steps.filter.outputs.backend == 'true'
run: pnpm --filter="@codedang/backend" exec tsc --noEmit

# Typecheck is not performed for frontend intentionally.
Expand Down Expand Up @@ -98,8 +149,8 @@ jobs:
- name: Lint (Node.js)
run: pnpm lint

test:
name: Test
test-backend:
name: Test Backend
runs-on: ubuntu-latest

env:
Expand All @@ -118,9 +169,21 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Check if source code has changed
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
backend:
- 'apps/backend/**'
- 'pnpm-lock.yaml'

- uses: ./.github/actions/setup-pnpm
if: steps.filter.outputs.backend == 'true'

- name: Check Prisma Migration
if: steps.filter.outputs.backend == 'true'
run: |
pnpm --filter="@codedang/backend" exec prisma migrate diff \
--from-migrations ./prisma/migrations \
Expand All @@ -131,7 +194,9 @@ jobs:
"Please run 'pnpm prisma migrate dev' locally and commit the changes." && exit 1)

- name: Migrate Prisma
if: steps.filter.outputs.backend == 'true'
run: pnpm --filter="@codedang/backend" exec prisma migrate reset --force

- name: Test
run: pnpm -r test
if: steps.filter.outputs.backend == 'true'
run: pnpm --filter="@codedang/backend" test
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ports:
- port: 15672 # RabbitMQ Dashboard
onOpen: ignore

- port: 30000 # Testcase Server
- port: 30000 # Storage Server
onOpen: ignore

tasks:
Expand Down
4 changes: 2 additions & 2 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### BUILDER ###
ARG target=client

FROM node:20.13.0-alpine AS builder
FROM node:20.15.0-alpine AS builder
ARG target

COPY . /build
Expand All @@ -18,7 +18,7 @@ RUN npx prisma generate
RUN npm run build ${target}

### PRODUCTION ###
FROM node:20.13.0-alpine
FROM node:20.15.0-alpine
ARG target

ENV NODE_ENV=production
Expand Down
7 changes: 7 additions & 0 deletions apps/backend/apps/admin/src/problem/model/image.output.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Field, ObjectType } from '@nestjs/graphql'

@ObjectType({ description: 'image' })
export class ImageSource {
@Field(() => String)
src: string
}
3 changes: 2 additions & 1 deletion apps/backend/apps/admin/src/problem/problem.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { StorageModule } from '@admin/storage/storage.module'
import { ProblemTagResolver, TagResolver } from './problem-tag.resolver'
import {
Expand All @@ -9,7 +10,7 @@ import {
import { ProblemService } from './problem.service'

@Module({
imports: [StorageModule],
imports: [StorageModule, ConfigModule],
providers: [
ProblemResolver,
ProblemTagResolver,
Expand Down
40 changes: 40 additions & 0 deletions apps/backend/apps/admin/src/problem/problem.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import {
} from '@nestjs/graphql'
import {
ContestProblem,
Image,
Problem,
ProblemTag,
ProblemTestcase,
WorkbookProblem
} from '@generated'
import { Prisma } from '@prisma/client'
import { PrismaClientKnownRequestError } from '@prisma/client/runtime/library'
import { AuthenticatedRequest } from '@libs/auth'
import { OPEN_SPACE_ID } from '@libs/constants'
import {
Expand All @@ -33,6 +35,7 @@ import {
UnprocessableDataException
} from '@libs/exception'
import { CursorValidationPipe, GroupIDPipe, RequiredIntPipe } from '@libs/pipe'
import { ImageSource } from './model/image.output'
import {
CreateProblemInput,
UploadFileInput,
Expand Down Expand Up @@ -105,6 +108,43 @@ export class ProblemResolver {
}
}

@Mutation(() => ImageSource)
async uploadImage(
@Args('input') input: UploadFileInput,
@Context('req') req: AuthenticatedRequest
) {
try {
return await this.problemService.uploadImage(input, req.user.id)
} catch (error) {
if (error instanceof UnprocessableDataException) {
throw error.convert2HTTPException()
}
this.logger.error(error)
throw new InternalServerErrorException()
}
}

@Mutation(() => Image)
async deleteImage(
@Args('filename') filename: string,
@Context('req') req: AuthenticatedRequest
) {
try {
return await this.problemService.deleteImage(filename, req.user.id)
} catch (error) {
if (error instanceof UnprocessableDataException) {
throw error.convert2HTTPException()
} else if (
error instanceof PrismaClientKnownRequestError &&
error.code == 'P2025'
) {
throw new NotFoundException(error.message)
}
this.logger.error(error)
throw new InternalServerErrorException()
}
}

@Query(() => [Problem])
async getProblems(
@Args(
Expand Down
Loading