codedang
codedang copied to clipboard
Problem 모델 분리
Describe the problem and solution
현재 Problem 모델:
model Problem {
id Int @id @default(autoincrement())
createdBy User? @relation(fields: [createdById], references: [id], onDelete: SetNull)
createdById Int? @map("created_by_id")
group Group @relation(fields: [groupId], references: [id])
groupId Int @map("group_id")
title String
description String
inputDescription String @map("input_description")
outputDescription String @map("output_description")
hint String
// 문제 정보의 영어 버전 제공은 선택사항임
engTitle String? @map("eng_title")
engDescription String? @map("eng_description")
engInputDescription String? @map("eng_input_description")
engOutputDescription String? @map("eng_output_description")
engHint String? @map("eng_hint")
/// template code item structure
/// {
/// "lanaguage": Language,
/// "code": {
/// "id": number,
/// "text": string,
/// "locked": boolean
/// }[]
/// }
isVisible Boolean @default(true) @map("is_visible")
template Json[]
languages Language[]
timeLimit Int @map("time_limit") // unit: MilliSeconds
memoryLimit Int @map("memory_limit") // unit: MegaBytes
difficulty Level
source String
submissionCount Int @default(0) @map("submission_count")
acceptedCount Int @default(0) @map("accepted_count")
acceptedRate Float @default(0) @map("accepted_rate")
exposeTime DateTime @default(now()) @map("expose_time")
createTime DateTime @default(now()) @map("create_time")
updateTime DateTime @updatedAt @map("update_time")
inputExamples String[] @map("input_examples")
outputExamples String[] @map("output_examples")
problemTestcase ProblemTestcase[]
problemTag ProblemTag[]
contestProblem ContestProblem[]
workbookProblem WorkbookProblem[]
submission Submission[]
announcement Announcement[]
codeDraft CodeDraft[]
@@map("problem")
}
너무 많은 속성들이 있기 때문에, 문제에 대한 설명 및 안내가 담기는 속성을 분리해 ProblemInfo 테이블을 생성합니다..
title, description, inputDescription, outputDescription, hint를 분리해 새로운 모델을 생성하고, 해당 모델에 problemLanguage 속성을 정의해 저장되는 문제 정보가 영어인지, 한국어인지 구분하도록 합니다. (따라서 engTitle, engDescription 등은 삭제)
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guidelines
- [X] Check that there isn't already an issue
https://github.com/skkuding/codedang/pull/1373 머지 후 작업예정
혹시 problem 모델 분리하는 이유가 단순히 필드가 많아서인가요? 필드가 많아서 테이블을 만드는 거면 구현이 번거로워지기도 하고 오히려 가독성을 해칠 수도 있지 않을까 걱정이어서요...
혹시 problem 모델 분리하는 이유가 단순히 필드가 많아서인가요? 필드가 많아서 테이블을 만드는 거면 구현이 번거로워지기도 하고 오히려 가독성을 해칠 수도 있지 않을까 걱정이어서요...
필드가 많기도 하고 engTitle, engDescription 등이 옵셔널 값으로 추가되면서 영어 버전 설명이 제공되지 않는 문제 데이터에 불필요한 null값들이 너무 많이 생긴다는 의견이 있어서 분리하기로 이야기 나누었었습니다!