-
Notifications
You must be signed in to change notification settings - Fork 16
feat(be): integrate Mandeuldang problem schema and read queries #3715
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
Open
yubbbbbbi
wants to merge
8
commits into
t2840-rename-polygon-to-mandeuldang
Choose a base branch
from
t2853-implement-mandeuldang-problem
base: t2840-rename-polygon-to-mandeuldang
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3f06689
feat(be): integrate Mandeuldang problem schema
yubbbbbbi 192c26b
fix(be): adapt references to unified problem model
yubbbbbbi 2f19c9f
chore(be): scaffold Mandeuldang problem module
yubbbbbbi a00f440
chore(be): scaffold Mandeuldang problem module
yubbbbbbi b547acf
feat(be): implement Mandeuldang problem read queries and legacy compa…
han25-ya 1503f55
Revert "feat(be): implement Mandeuldang problem read queries and lega…
han25-ya 0652c80
Reapply "feat(be): implement Mandeuldang problem read queries and leg…
han25-ya 41f72b1
fix(be): keep legacy Problem response contract non-null
han25-ya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
49 changes: 49 additions & 0 deletions
49
apps/backend/apps/admin/src/mandeuldang/problem/model/problem.output.ts
This file contains hidden or 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,49 @@ | ||
| import { Field, Int, ObjectType } from '@nestjs/graphql' | ||
| import { CollaboratorRole, Problem } from '@admin/@generated' | ||
|
|
||
| /** | ||
| * 만들당 문제 상세/목록 조회 결과. | ||
| * | ||
| * DB는 MandeuldangProblem이라는 별도 모델 없이 기존 Problem을 그대로 쓰기로 결정됐으므로 | ||
| * (백엔드 회의 08.20 결론), 자동 생성된 Problem GraphQL 타입을 그대로 확장한다 — | ||
| * ProblemWithIsVisible(../../problem/model/problem.output.ts)이 이미 같은 패턴을 쓰고 있다. | ||
| * | ||
| * 목록 전용 Output 타입은 따로 만들지 않았다. 목록 조회에서는 아래 관계·계산 필드를 | ||
| * 채우지 않고 undefined로 두면 되므로(전부 nullable), 상세 조회와 타입을 공유해도 | ||
| * 계약이 깨지지 않는다. | ||
| */ | ||
| @ObjectType() | ||
| export class MandeuldangProblemOutput extends Problem { | ||
| @Field(() => CollaboratorRole, { | ||
| nullable: true, | ||
| description: | ||
| '요청한 사용자가 이 문제에 대해 가진 협업 역할. Owner/Editor/Reviewer가 아니면 null.' | ||
| }) | ||
| myRole?: `${CollaboratorRole}` | null | ||
|
|
||
| // mandeuldangCollaborators/mandeuldangSolution/mandeuldangTools는 기존 생성된 | ||
| // Problem 타입에 이미 관계 필드로 선언돼 있어(부모 필드) 여기서 다시 선언하지 않는다 — | ||
| // 서비스가 Prisma include로 채워 넣은 값이 그대로 상속된 필드에 실린다. | ||
|
|
||
| @Field(() => Int, { | ||
| nullable: true, | ||
| description: '등록된 테스트 파일(.in/.out 쌍 기준이 아니라 개별 파일 개수)' | ||
| }) | ||
| testFileCount?: number | ||
|
|
||
| @Field(() => Boolean, { | ||
| nullable: true, | ||
| description: | ||
| '지금 상태로 발행 가능한지 여부. 상세 조회에서만 계산해 채운다.' | ||
| }) | ||
| canPublish?: boolean | ||
|
|
||
| @Field(() => [String], { | ||
| nullable: true, | ||
| description: | ||
| 'canPublish가 false일 때 무엇이 부족한지 나타내는 코드 목록 ' + | ||
| '(STATEMENT/SOLUTION/TEST_FILES). 실제 발행 가능 여부의 최종 판단과 발행 자체는 ' + | ||
| 'Update/발행 담당 쪽에서 이뤄지므로, 이 값은 참고용 미리보기다.' | ||
| }) | ||
| missingForPublish?: string[] | ||
| } |
8 changes: 8 additions & 0 deletions
8
apps/backend/apps/admin/src/mandeuldang/problem/problem.module.ts
This file contains hidden or 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 { MandeuldangProblemResolver } from './resolvers/problem.resolver' | ||
| import { MandeuldangProblemService } from './services/problem.service' | ||
|
|
||
| @Module({ | ||
| providers: [MandeuldangProblemService, MandeuldangProblemResolver] | ||
| }) | ||
| export class MandeuldangProblemModule {} |
92 changes: 92 additions & 0 deletions
92
apps/backend/apps/admin/src/mandeuldang/problem/resolvers/problem.resolver.spec.ts
This file contains hidden or 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,92 @@ | ||
| import { Test, type TestingModule } from '@nestjs/testing' | ||
| import { ProblemStatus, Role } from '@prisma/client' | ||
| import { expect } from 'chai' | ||
| import { stub } from 'sinon' | ||
| import type { AuthenticatedRequest } from '@libs/auth' | ||
| import { MandeuldangProblemService } from '../services/problem.service' | ||
| import { MandeuldangProblemResolver } from './problem.resolver' | ||
|
|
||
| const problemService = { | ||
| getMyProblems: stub(), | ||
| getInProgressProblems: stub(), | ||
| getProblem: stub() | ||
| } | ||
|
|
||
| const req = { | ||
| user: { id: 1, role: Role.User } | ||
| } as unknown as AuthenticatedRequest | ||
|
|
||
| describe('MandeuldangProblemResolver', () => { | ||
| let resolver: MandeuldangProblemResolver | ||
|
|
||
| beforeEach(async () => { | ||
| problemService.getMyProblems.reset() | ||
| problemService.getInProgressProblems.reset() | ||
| problemService.getProblem.reset() | ||
|
|
||
| const module: TestingModule = await Test.createTestingModule({ | ||
| providers: [ | ||
| MandeuldangProblemResolver, | ||
| { provide: MandeuldangProblemService, useValue: problemService } | ||
| ] | ||
| }).compile() | ||
|
|
||
| resolver = module.get<MandeuldangProblemResolver>( | ||
| MandeuldangProblemResolver | ||
| ) | ||
| }) | ||
|
|
||
| it('should be defined', () => { | ||
| expect(resolver).to.be.ok | ||
| }) | ||
|
|
||
| it('getMyMandeuldangProblems delegates to the service with the requester id', async () => { | ||
| problemService.getMyProblems.resolves([]) | ||
|
|
||
| await resolver.getMyMandeuldangProblems(req, null, 10, undefined) | ||
|
|
||
| expect( | ||
| problemService.getMyProblems.calledOnceWith(1, null, 10, undefined) | ||
| ).to.equal(true) | ||
| }) | ||
|
|
||
| it('getMyMandeuldangProblems forwards an explicit status filter', async () => { | ||
| problemService.getMyProblems.resolves([]) | ||
|
|
||
| await resolver.getMyMandeuldangProblems(req, null, 10, ProblemStatus.Draft) | ||
|
|
||
| expect( | ||
| problemService.getMyProblems.calledOnceWith( | ||
| 1, | ||
| null, | ||
| 10, | ||
| ProblemStatus.Draft | ||
| ) | ||
| ).to.equal(true) | ||
| }) | ||
|
|
||
| it('getInProgressMandeuldangProblems delegates to the service with the requester id', async () => { | ||
| problemService.getInProgressProblems.resolves([]) | ||
|
|
||
| await resolver.getInProgressMandeuldangProblems(req, null, 10, undefined) | ||
|
|
||
| expect( | ||
| problemService.getInProgressProblems.calledOnceWith( | ||
| 1, | ||
| null, | ||
| 10, | ||
| undefined | ||
| ) | ||
| ).to.equal(true) | ||
| }) | ||
|
|
||
| it('getMandeuldangProblem delegates to the service with id, requester id, and role', async () => { | ||
| problemService.getProblem.resolves({}) | ||
|
|
||
| await resolver.getMandeuldangProblem(req, 42) | ||
|
|
||
| expect(problemService.getProblem.calledOnceWith(42, 1, Role.User)).to.equal( | ||
| true | ||
| ) | ||
| }) | ||
| }) |
54 changes: 54 additions & 0 deletions
54
apps/backend/apps/admin/src/mandeuldang/problem/resolvers/problem.resolver.ts
This file contains hidden or 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,54 @@ | ||
| import { Args, Context, Int, Query, Resolver } from '@nestjs/graphql' | ||
| import { ProblemStatus } from '@prisma/client' | ||
| import { AuthenticatedRequest, UseDisableAdminGuard } from '@libs/auth' | ||
| import { CursorValidationPipe, RequiredIntPipe } from '@libs/pipe' | ||
| import { MandeuldangProblemOutput } from '../model/problem.output' | ||
| import { MandeuldangProblemService } from '../services/problem.service' | ||
|
|
||
| @Resolver(() => MandeuldangProblemOutput) | ||
| @UseDisableAdminGuard() | ||
| export class MandeuldangProblemResolver { | ||
| constructor(private readonly problemService: MandeuldangProblemService) {} | ||
|
|
||
| @Query(() => [MandeuldangProblemOutput]) | ||
| async getMyMandeuldangProblems( | ||
| @Context('req') req: AuthenticatedRequest, | ||
| @Args('cursor', { nullable: true, type: () => Int }, CursorValidationPipe) | ||
| cursor: number | null, | ||
| @Args('take', { defaultValue: 10, type: () => Int }) take: number, | ||
| @Args('status', { nullable: true, type: () => ProblemStatus }) | ||
| status?: ProblemStatus | ||
| ) { | ||
| return await this.problemService.getMyProblems( | ||
| req.user.id, | ||
| cursor, | ||
| take, | ||
| status | ||
| ) | ||
| } | ||
|
|
||
| @Query(() => [MandeuldangProblemOutput]) | ||
| async getInProgressMandeuldangProblems( | ||
| @Context('req') req: AuthenticatedRequest, | ||
| @Args('cursor', { nullable: true, type: () => Int }, CursorValidationPipe) | ||
| cursor: number | null, | ||
| @Args('take', { defaultValue: 10, type: () => Int }) take: number, | ||
| @Args('status', { nullable: true, type: () => ProblemStatus }) | ||
| status?: ProblemStatus | ||
| ) { | ||
| return await this.problemService.getInProgressProblems( | ||
| req.user.id, | ||
| cursor, | ||
| take, | ||
| status | ||
| ) | ||
| } | ||
|
|
||
| @Query(() => MandeuldangProblemOutput) | ||
| async getMandeuldangProblem( | ||
| @Context('req') req: AuthenticatedRequest, | ||
| @Args('id', { type: () => Int }, new RequiredIntPipe('id')) id: number | ||
| ) { | ||
| return await this.problemService.getProblem(id, req.user.id, req.user.role) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Enforce a maximum
takevalue for both list queries.defaultValue: 10does not cap supplied values. A caller can request an arbitrarily large page, and both service methods pass that value directly to Prisma. Apply the existing project page-size validation policy, or clamp the value in the service.apps/backend/apps/admin/src/mandeuldang/problem/resolvers/problem.resolver.ts#L18-L18: validatetakeagainst a positive maximum.apps/backend/apps/admin/src/mandeuldang/problem/resolvers/problem.resolver.ts#L35-L35: apply the same maximum.📍 Affects 1 file
apps/backend/apps/admin/src/mandeuldang/problem/resolvers/problem.resolver.ts#L18-L18(this comment)apps/backend/apps/admin/src/mandeuldang/problem/resolvers/problem.resolver.ts#L35-L35🤖 Prompt for AI Agents