From a684dbd1fdf6134119413041166e5b2eee0e671d Mon Sep 17 00:00:00 2001 From: river0525 <0525sotaro@gmail.com> Date: Fri, 13 Mar 2026 07:52:54 +0900 Subject: [PATCH 01/26] =?UTF-8?q?add:=20schema.prisma=E3=81=AB=E6=8A=95?= =?UTF-8?q?=E7=A5=A8=E6=A9=9F=E8=83=BD=E3=81=AB=E5=BF=85=E8=A6=81=E3=81=AA?= =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=96=E3=83=AB=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/schema.prisma | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a0edd4aee..340477ba3 100755 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -236,6 +236,44 @@ model WorkBookTask { @@map("workbooktask") } +model VoteGrade { + id String @id @default(uuid()) + userId String + taskId String + grade TaskGrade + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + user User @relation(references: [id], fields: [userId]) + task Task @relation(references: [task_id], fields: [taskId]) + + @@unique([userId, taskId]) + @@map("votegrade") +} + +model VotedGradeCounter { + id String @id @default(uuid()) + taskId String + grade TaskGrade + count Int + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@map("votedgradecounter") +} + +model VotedGradeStatistics { + id String @id @default(uuid()) + taskId String + grade TaskGrade + isExperimental Boolean @default(false) + isApproved Boolean @default(true) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@map("votedgradestatistics") +} + enum ContestType { ABC // AtCoder Beginner Contest APG4B // C++入門 AtCoder Programming Guide for beginners From 068e6b972d451f07f7bfc5fb81267a90b2030aac Mon Sep 17 00:00:00 2001 From: river0525 <0525sotaro@gmail.com> Date: Sun, 15 Mar 2026 09:58:23 +0900 Subject: [PATCH 02/26] =?UTF-8?q?fix:=20relation=E3=81=AE=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E4=B8=8D=E8=B6=B3=EF=BC=86=E3=83=9E=E3=82=A4=E3=82=B0?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E5=BF=98=E3=82=8C?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prisma/ERD.md | 36 +++++++++++++++ .../migration.sql | 45 +++++++++++++++++++ prisma/schema.prisma | 2 + 3 files changed, 83 insertions(+) create mode 100644 prisma/migrations/20260315003958_add_vote_table/migration.sql diff --git a/prisma/ERD.md b/prisma/ERD.md index d60e4edc5..39c8222d0 100644 --- a/prisma/ERD.md +++ b/prisma/ERD.md @@ -237,6 +237,37 @@ ANALYSIS ANALYSIS DateTime updatedAt } + + "votegrade" { + String id "🗝️" + String userId + String taskId + TaskGrade grade + DateTime createdAt + DateTime updatedAt + } + + + "votedgradecounter" { + String id "🗝️" + String taskId + TaskGrade grade + Int count + DateTime createdAt + DateTime updatedAt + } + + + "votedgradestatistics" { + String id "🗝️" + String taskId + TaskGrade grade + Boolean isExperimental + Boolean isApproved + DateTime createdAt + DateTime updatedAt + } + "user" |o--|| "Roles" : "enum:role" "session" }o--|| user : "user" "key" }o--|| user : "user" @@ -255,4 +286,9 @@ ANALYSIS ANALYSIS "workbookplacement" |o--|| workbook : "workBook" "workbooktask" }o--|| workbook : "workBook" "workbooktask" }o--|| task : "task" + "votegrade" |o--|| "TaskGrade" : "enum:grade" + "votegrade" }o--|| user : "user" + "votegrade" }o--|| task : "task" + "votedgradecounter" |o--|| "TaskGrade" : "enum:grade" + "votedgradestatistics" |o--|| "TaskGrade" : "enum:grade" ``` diff --git a/prisma/migrations/20260315003958_add_vote_table/migration.sql b/prisma/migrations/20260315003958_add_vote_table/migration.sql new file mode 100644 index 000000000..f4ee8829b --- /dev/null +++ b/prisma/migrations/20260315003958_add_vote_table/migration.sql @@ -0,0 +1,45 @@ +-- CreateTable +CREATE TABLE "votegrade" ( + "id" TEXT NOT NULL, + "userId" TEXT NOT NULL, + "taskId" TEXT NOT NULL, + "grade" "TaskGrade" NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "votegrade_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "votedgradecounter" ( + "id" TEXT NOT NULL, + "taskId" TEXT NOT NULL, + "grade" "TaskGrade" NOT NULL, + "count" INTEGER NOT NULL, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "votedgradecounter_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "votedgradestatistics" ( + "id" TEXT NOT NULL, + "taskId" TEXT NOT NULL, + "grade" "TaskGrade" NOT NULL, + "isExperimental" BOOLEAN NOT NULL DEFAULT false, + "isApproved" BOOLEAN NOT NULL DEFAULT true, + "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMP(3) NOT NULL, + + CONSTRAINT "votedgradestatistics_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "votegrade_userId_taskId_key" ON "votegrade"("userId", "taskId"); + +-- AddForeignKey +ALTER TABLE "votegrade" ADD CONSTRAINT "votegrade_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "votegrade" ADD CONSTRAINT "votegrade_taskId_fkey" FOREIGN KEY ("taskId") REFERENCES "task"("task_id") ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 340477ba3..2ef912878 100755 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -55,6 +55,7 @@ model User { key Key[] taskAnswer TaskAnswer[] workBooks WorkBook[] + voteGrade VoteGrade[] @@map("user") } @@ -104,6 +105,7 @@ model Task { tags TaskTag[] task_answers TaskAnswer[] workBookTasks WorkBookTask[] + voteGrade VoteGrade[] @@map("task") } From 8f45a8d835765a6a500da58d9fcf7643e265eb7c Mon Sep 17 00:00:00 2001 From: river0525 <0525sotaro@gmail.com> Date: Fri, 20 Mar 2026 01:52:05 +0900 Subject: [PATCH 03/26] =?UTF-8?q?add:=20=E6=8A=95=E7=A5=A8=E7=94=A8?= =?UTF-8?q?=E3=83=89=E3=83=AD=E3=83=83=E3=83=97=E3=83=80=E3=82=A6=E3=83=B3?= =?UTF-8?q?=E3=82=92=E5=87=BA=E3=81=99=E6=A9=9F=E8=83=BD=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contest-table/TaskTableBodyCell.svelte | 11 +-- .../contest-table/VotableGrade.svelte | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 src/features/tasks/components/contest-table/VotableGrade.svelte diff --git a/src/features/tasks/components/contest-table/TaskTableBodyCell.svelte b/src/features/tasks/components/contest-table/TaskTableBodyCell.svelte index 662f74948..36a2aec74 100644 --- a/src/features/tasks/components/contest-table/TaskTableBodyCell.svelte +++ b/src/features/tasks/components/contest-table/TaskTableBodyCell.svelte @@ -1,7 +1,7 @@ + + +
+ 集計済み統計一覧(3票以上で暫定グレードが算出されます) +
+ +
+
+ 暫定グレード:{getTaskGradeLabel(data.stats.grade)}({totalVotes}票) +
+ {/if} + + ++ この問題のグレードを投票してください。投票後に集計結果を確認できます。 +
+ {@render voteForm()} + {:else} + +投票するにはログインが必要です。
++ ※ 3票以上集まると中央値が暫定グレードとして一覧表に反映されます。 +
{@render voteForm()} {:else} From 0cf12da7ad6b6f6e2b0cfc045c78a7d7006e3931 Mon Sep 17 00:00:00 2001 From: river0525 <0525sotaro@gmail.com> Date: Tue, 24 Mar 2026 19:41:19 +0900 Subject: [PATCH 14/26] =?UTF-8?q?fix:=20=E6=8A=95=E7=A5=A8=E8=A9=B3?= =?UTF-8?q?=E7=B4=B0=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE=E8=AA=AC=E6=98=8E?= =?UTF-8?q?=E6=96=87=E3=82=92=E6=8A=95=E7=A5=A8=E5=BE=8C=E3=82=82=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 「3票以上集まると一覧表に反映される」の説明を {#if} ブロック外に移動し、 投票前・投票後・未ログインのいずれの状態でも常に表示されるようにした。 Co-Authored-By: Claude Sonnet 4.6+ ※ 3票以上集まると中央値が暫定グレードとして一覧表に反映されます。 +
+ {#if data.myVote?.voted} @@ -111,9 +115,6 @@この問題のグレードを投票してください。投票後に集計結果を確認できます。
-- ※ 3票以上集まると中央値が暫定グレードとして一覧表に反映されます。 -
{@render voteForm()} {:else} From c6ed2ca7925eced78bbbbecc35832ba26d138dda Mon Sep 17 00:00:00 2001 From: river0525 <0525sotaro@gmail.com> Date: Tue, 24 Mar 2026 19:59:03 +0900 Subject: [PATCH 15/26] =?UTF-8?q?fix:=E3=80=80=E8=A9=B3=E7=B4=B0=E3=83=9A?= =?UTF-8?q?=E3=83=BC=E3=82=B8=E3=81=B8=E3=81=AE=E9=81=B7=E7=A7=BB=E3=82=92?= =?UTF-8?q?=E3=83=89=E3=83=AD=E3=83=83=E3=83=97=E3=83=80=E3=82=A6=E3=83=B3?= =?UTF-8?q?=E3=81=AE=E6=A8=AA=E5=B9=85=E3=81=AB=E5=90=88=E3=81=86=E8=A1=A8?= =?UTF-8?q?=E8=A8=98=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../votes/components/VotableGrade.svelte | 2 +- src/routes/votes/[slug]/+page.svelte | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/features/votes/components/VotableGrade.svelte b/src/features/votes/components/VotableGrade.svelte index 0a947f34a..a1936f2d1 100644 --- a/src/features/votes/components/VotableGrade.svelte +++ b/src/features/votes/components/VotableGrade.svelte @@ -180,7 +180,7 @@ {/each}