Skip to content

feat(admin): enable to search tasks and update grade in admin page#3689

Merged
KATO-Hiro merged 6 commits into
stagingfrom
#3581
Jun 18, 2026
Merged

feat(admin): enable to search tasks and update grade in admin page#3689
KATO-Hiro merged 6 commits into
stagingfrom
#3581

Conversation

@KATO-Hiro

@KATO-Hiro KATO-Hiro commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

close #3581

Summary by CodeRabbit

リリースノート

  • 新機能

    • 管理者向け「グレード管理」ページ(/tasks/grade)を追加し、タスクのグレードを検索・一括更新できるようになりました。
  • 削除

    • 「投票管理」ページ(/vote_management)を削除しました。
  • UI更新

    • ナビゲーションメニューを更新し、「投票管理」から「グレード管理」へ切り替えました。
  • テスト

    • グレード管理に関するE2Eテストを追加・更新しました。未認証/非管理ユーザーのリダイレクト確認も反映しました。

KATO-Hiro and others added 4 commits June 18, 2026 11:40
Move the admin grading page from /vote_management to /tasks/grade,
update navbar links, and remove the now-unused isAdmin prop from
problems page since grading is admin-only via the new dedicated route.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

管理者向けの /vote_management ページを廃止し、/tasks/grade として再実装。getAllTasksWithVoteInfo() 単一呼び出しによるデータ取得、検索・ソート・グレード更新UIを新設。isAdmin prop をコンポーネント群から除去し、ナビゲーション定数・e2eテストも新ルートに対応させた。

Changes

グレード管理ページへの移行

Layer / File(s) Summary
ナビゲーション定数の切り替え
src/lib/constants/navbar-links.ts
VOTE_MANAGEMENT_PAGE を削除し TASKS_GRADE_PAGE = '/tasks/grade' を追加。navbarDashboardLinks の「投票管理」を「グレード管理」に置き換え。
サーバー側データ取得の簡素化
src/routes/(admin)/tasks/grade/+page.server.ts
Promise.all による複数取得を getAllTasksWithVoteInfo() 単一呼び出しに統一。返却キーを statstasks に変更。
グレード管理ページUI実装
src/routes/(admin)/tasks/grade/+page.svelte
検索・ソート・最大20件フィルタ・adminGradeCell スニペット(POST フォーム・GradeLabel・相対評価バッジ)を実装。
コンポーネント群から isAdmin を除去
src/lib/components/TaskGradeList.svelte, src/lib/components/TaskList.svelte, src/routes/problems/+page.server.ts, src/routes/problems/+page.svelte
isAdmin prop・派生変数・Roles import を削除。TaskList の「編集」リンク分岐と PENDING 管理者表示を除去。
e2e テストの切り替え
e2e/redirect_after_login.spec.ts, e2e/votes.spec.ts
adminRoutes を /vote_management/tasks/grade に更新。認証状態別リダイレクト・UI要素(検索入力・列ヘッダー)の検証テストを新設。旧ページのテストは削除。

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AtCoder-NoviSteps/AtCoderNoviSteps#3416: 本PRが全削除する (admin)/vote_management/+page.svelteRelativeEvaluationBadge を追加したPRであり、同一コードパスで直接競合。
  • AtCoder-NoviSteps/AtCoderNoviSteps#1599: src/routes/problems/+page.svelteGradeGuidelineTable 追加時に isAdmin 使用が検討される可能性があり、本PRの isAdmin 削除と競合リスク。
  • AtCoder-NoviSteps/AtCoderNoviSteps#1676: src/routes/problems/+page.svelte のタブUI制御(isOpen 派生値)で同じコンポーネントを修正するため、マージ順序に注意が必要。

Poem

🗳️ 投票管理よ、さようなら
/tasks/grade へと引っ越しだ
isAdmin の橋も壊して
getAllTasksWithVoteInfo() 一本で
管理者の夢、スッキリ叶う ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed 全6つの主要目標を実装済み:ルート移行、全問題対応、検索機能追加、ソート統一、グレード編集UI維持、リンク削除。既存サービス再利用で新規関数不要。
Out of Scope Changes check ✅ Passed 変更は Issue #3581 の指定範囲に完全に準拠。スコープ外項目(レガシールート削除、キャッシュ、UI刷新)は実装されていません。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed PRのタイトルはタスク検索機能の追加とグレード更新機能を的確に説明しており、主要な変更内容を明確に要約しています。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch #3581

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/routes/(admin)/tasks/grade/+page.server.ts (1)

17-30: ⚠️ Potential issue | 🟠 Major

フォーム検証を Superforms + Zod に統一してください(Line 17-30)。

setTaskGrade が手動 formData パースのままで、ルート層フォーム実装の統一規約から外れています。プロジェクト内の workbooks、problems、votes など複数のルートで既に Superforms + Zod が採用されており、このファイルも同様に統一してください。

TaskGrade の Zod スキーマを定義した上で、superValidate + Zod による型安全な検証と一貫性のあるエラーレスポンスに寄せてください。

修正イメージ
+import { superValidate } from 'sveltekit-superforms/server';
+import { zod4 } from 'sveltekit-superforms/adapters';
+import { z } from 'zod';

+const setTaskGradeSchema = z.object({
+  taskId: z.string().min(1),
+  grade: z.nativeEnum(TaskGradeEnum),
+});

   setTaskGrade: async ({ request, locals }) => {
     await validateAdminAccess(locals);
-    const data = await request.formData();
-    const taskId = data.get('taskId');
-    const grade = data.get('grade');
-    if (...) return { success: false };
+    const form = await superValidate(request, zod4(setTaskGradeSchema));
+    if (!form.valid) return { success: false, form };
+    const { taskId, grade } = form.data;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/`(admin)/tasks/grade/+page.server.ts around lines 17 - 30, The
setTaskGrade action is currently using manual formData parsing and validation
instead of the Superforms + Zod pattern used throughout the project. Create a
Zod schema for TaskGrade validation that includes the taskId and grade fields
with appropriate constraints, then replace the manual formData parsing and
if-statement validation with a superValidate call passing the request and the
TaskGrade schema. This will provide type-safe validation and consistent error
responses aligned with the rest of the codebase.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/votes.spec.ts`:
- Line 7: The variable TASKS_GRADE_URL uses UPPER_SNAKE_CASE naming convention,
but the coding guidelines require camelCase for variables in TypeScript files.
Rename the constant TASKS_GRADE_URL to tasksGradeUrl throughout the file, and
update all references to this variable to use the new camelCase name.

In `@src/routes/problems/`+page.server.ts:
- Around line 42-45: The condition `tagIds != null` in the const taskResults
assignment doesn't properly handle empty string values. When tagIds is an empty
string (e.g., ?tagIds=), the condition evaluates to true and calls
getTasksWithTagIds, but empty strings should be treated as unspecified. Modify
the condition to check that tagIds is not only non-null but also non-empty (has
actual content), so that empty string values fall through to the default
getTaskResults call instead.

---

Outside diff comments:
In `@src/routes/`(admin)/tasks/grade/+page.server.ts:
- Around line 17-30: The setTaskGrade action is currently using manual formData
parsing and validation instead of the Superforms + Zod pattern used throughout
the project. Create a Zod schema for TaskGrade validation that includes the
taskId and grade fields with appropriate constraints, then replace the manual
formData parsing and if-statement validation with a superValidate call passing
the request and the TaskGrade schema. This will provide type-safe validation and
consistent error responses aligned with the rest of the codebase.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 57ff5c0d-8390-4326-9820-eefe9b7cb6d3

📥 Commits

Reviewing files that changed from the base of the PR and between 892e22f and 091390c.

📒 Files selected for processing (10)
  • e2e/redirect_after_login.spec.ts
  • e2e/votes.spec.ts
  • src/lib/components/TaskGradeList.svelte
  • src/lib/components/TaskList.svelte
  • src/lib/constants/navbar-links.ts
  • src/routes/(admin)/tasks/grade/+page.server.ts
  • src/routes/(admin)/tasks/grade/+page.svelte
  • src/routes/(admin)/vote_management/+page.svelte
  • src/routes/problems/+page.server.ts
  • src/routes/problems/+page.svelte
💤 Files with no reviewable changes (1)
  • src/routes/(admin)/vote_management/+page.svelte

Comment thread e2e/votes.spec.ts
Comment thread src/routes/problems/+page.server.ts
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
src/routes/problems/+page.server.ts (1)

43-45: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

tagIds の空白のみ入力が未指定扱いになっていません(Line 43)。

  • '' は回避できていますが、' ' は truthy のため getTasksWithTagIds 側に入ります。
  • 未指定扱いにしたいなら trim() を条件に含めるのが安全です。
修正案
-  const taskResults = (
-    tagIds
-      ? await task_crud.getTasksWithTagIds(tagIds, session?.user.userId)
+  const normalizedTagIds = tagIds?.trim();
+  const taskResults = (
+    normalizedTagIds
+      ? await task_crud.getTasksWithTagIds(normalizedTagIds, session?.user.userId)
       : await task_crud.getTaskResults(session?.user.userId)
   ) as TaskResults;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/routes/problems/`+page.server.ts around lines 43 - 45, The ternary
conditional checking tagIds does not properly handle whitespace-only strings as
unspecified input. When tagIds contains only spaces, it evaluates as truthy and
incorrectly passes to getTasksWithTagIds instead of falling back to
getTaskResults. Add trim() to the tagIds value in the conditional check so that
whitespace-only strings are properly treated as unspecified and the code
correctly calls getTaskResults as a fallback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@src/routes/problems/`+page.server.ts:
- Around line 43-45: The ternary conditional checking tagIds does not properly
handle whitespace-only strings as unspecified input. When tagIds contains only
spaces, it evaluates as truthy and incorrectly passes to getTasksWithTagIds
instead of falling back to getTaskResults. Add trim() to the tagIds value in the
conditional check so that whitespace-only strings are properly treated as
unspecified and the code correctly calls getTaskResults as a fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 99f505ac-b49f-4ea7-9ad2-e2f4c0ddb0bc

📥 Commits

Reviewing files that changed from the base of the PR and between 091390c and 6554b62.

📒 Files selected for processing (1)
  • src/routes/problems/+page.server.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@KATO-Hiro KATO-Hiro changed the title feat(admin): rename vote_management to tasks/grade route feat(admin): enable to search tasks and update grade in admin page Jun 18, 2026

@KATO-Hiro KATO-Hiro left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@KATO-Hiro KATO-Hiro merged commit c2681ba into staging Jun 18, 2026
3 checks passed
@KATO-Hiro KATO-Hiro deleted the #3581 branch June 18, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] 管理者画面: 問題を検索・画面遷移なしでグレーディングできるように改修しましょう

1 participant