Skip to content

[feat] 問題集の詳細ページで管理者と投票結果の差分を表すアイコンを表示する#3588

Merged
KATO-Hiro merged 4 commits into
stagingfrom
feature/#3582-workbook-diff-icon
May 25, 2026
Merged

[feat] 問題集の詳細ページで管理者と投票結果の差分を表すアイコンを表示する#3588
KATO-Hiro merged 4 commits into
stagingfrom
feature/#3582-workbook-diff-icon

Conversation

@river0525
Copy link
Copy Markdown
Collaborator

@river0525 river0525 commented May 25, 2026

Summary

Changes

  • src/routes/workbooks/[slug]/+page.server.ts: getVoteGradeStatistics()taskResultsCrud.getTaskResultsByTaskId()Promise.all で並列取得し、voteStatisticsMap を返す
  • src/routes/workbooks/[slug]/+page.svelte: RelativeEvaluationBadge をインポートし、グレードアイコンの右上に差分バッジを表示(確定グレードかつ投票中央値がある場合のみ)

Test plan

  • 確定グレードが付いたタスクを含む問題集の詳細ページで、グレードアイコン右上に差分バッジ(++/+/±0/-/--)が表示されることを確認
  • PENDING グレードのタスクにはバッジが表示されないことを確認
  • 投票中央値がないタスク(未投票)にはバッジが表示されないことを確認
  • pnpm format && pnpm check && pnpm test:unit がすべてパスすることを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • 新機能
    • 各問題行に投票統計に基づく相対評価バッジを表示するようになりました。グレード統計が利用可能な場合、バッジが表示されます。
  • パフォーマンス
    • 問題一覧のデータ取得が並列化され、読み込みがより速くなりました。
  • テスト
    • 投票統計取得ロジックの挙動を検証するテストを追加しました。

Fetch vote grade statistics alongside task results in parallel and display
RelativeEvaluationBadge on each task's grade icon when the task has a
confirmed grade and a known vote median.

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

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4e861a53-08f6-423a-b845-a6220fe0c2ad

📥 Commits

Reviewing files that changed from the base of the PR and between e0c84fe and 8970480.

📒 Files selected for processing (3)
  • src/features/votes/services/vote_statistics.test.ts
  • src/features/votes/services/vote_statistics.ts
  • src/routes/workbooks/[slug]/+page.server.ts

📝 Walkthrough

Walkthrough

サーバー側でタスク結果と投票グレード統計を並列取得して返し、クライアント側で受け取った voteStatisticsMap を使って各タスク行に相対評価バッジを条件付きレンダリングします。

Changes

投票統計に基づく相対評価バッジ表示

Layer / File(s) Summary
vote_statistics: タスク指定での統計取得とテスト追加
src/features/votes/services/vote_statistics.ts, src/features/votes/services/vote_statistics.test.ts
getVoteGradeStatisticsForTaskIds(taskIds: string[]) を追加。空入力で空の Map を返し、非空時は taskId IN (...) で絞って結果を Map に整形する。対応するユニットテストを追加。
サーバー: taskResults と voteStatisticsMap の並列取得
src/routes/workbooks/[slug]/+page.server.ts
getVoteGradeStatisticsForTaskIds を import し、taskResultsvoteStatisticsMapPromise.all で並列取得して返却オブジェクトに voteStatisticsMap を追加。
クライアント: 相対評価バッジのUIレンダリング
src/routes/workbooks/[slug]/+page.svelte
RelativeEvaluationBadge を import し、data.voteStatisticsMap$derived 化。各行で taskGradestatsEntry を確定して、PENDING でなく統計が存在する場合にバッジを表示するように変更。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • #3582: 本PRは管理者と投票結果の差分を示すアイコン/バッジ表示をワークブック詳細で実装しています。

Possibly related PRs

Suggested reviewers

  • KATO-Hiro

Poem

📊 投票の声を集めて並列に、
サーバーは速く統計を返す。
クライアントはバッジで差を示し、
行ごとに評価の光るアイコン、
小さな変更、大きな見やすさ。 ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトルは「問題集の詳細ページで管理者と投票結果の差分を表すアイコンを表示する」で、raw_summaryの全ての変更内容(RelativeEvaluationBadgeの追加、voteStatisticsMapの並列取得、投票統計クエリの最適化)と完全に一致しており、主要な変更を適切に要約しています。
Linked Issues check ✅ Passed PR内容は#3582の要件である「問題集詳細ページで差分アイコンを表示」「投票統計の並列取得」を完全に実装し、テストも追加されており、全ての主要な目的が達成されています。
Out of Scope Changes check ✅ Passed 全ての変更が#3582の要件「差分バッジ表示」「投票統計並列取得」「クエリ最適化」に直結しており、スコープ外の変更は検出されていません。

✏️ 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 feature/#3582-workbook-diff-icon

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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/routes/workbooks/`[slug]/+page.server.ts:
- Around line 40-43: getVoteGradeStatistics currently loads global vote
statistics via findMany for every request; change it to accept a list of taskIds
(e.g., taskIds: string[]) and return statistics filtered to only those taskIds
so we don't scan all rows. Update the call in +page.server.ts (where
getVoteGradeStatistics() is invoked alongside
taskResultsCrud.getTaskResultsByTaskId) to pass workBook.workBookTasks.map(t =>
t.taskId) (or similar) and rename or add a helper (e.g.,
getVoteGradeStatisticsForTaskIds) if you prefer non-breaking changes; ensure the
DB query uses a WHERE IN (taskId) filter and returns the same shape used by the
page.
🪄 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: 77c8842e-9bcb-45b2-8a29-a400e4f23888

📥 Commits

Reviewing files that changed from the base of the PR and between 2abae1a and e0c84fe.

📒 Files selected for processing (2)
  • src/routes/workbooks/[slug]/+page.server.ts
  • src/routes/workbooks/[slug]/+page.svelte

Comment thread src/routes/workbooks/[slug]/+page.server.ts
river0525 and others added 2 commits May 25, 2026 09:22
Replace the full-table getVoteGradeStatistics() with a new
getVoteGradeStatisticsForTaskIds() that issues a WHERE IN query,
avoiding a full scan of votedGradeStatistics on each workbook page load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

問題集詳細ページ(/workbooks/[slug])のグレード表示に、管理者確定グレードと投票中央値の差分を示す RelativeEvaluationBadge を重ねて表示できるようにするPRです。サーバ側では投票統計をタスク結果と並列に取得してページへ渡します。

Changes:

  • 問題集詳細ページのサーバ load で、タスク結果と投票統計を Promise.all で並列取得し voteStatisticsMap を返却
  • 問題集詳細ページのグレード列で、確定グレードかつ投票統計がある場合に差分バッジを表示
  • 投票統計サービスに taskId 配列で絞り込む取得関数を追加し、ユニットテストを追加

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/routes/workbooks/[slug]/+page.server.ts タスク結果と投票統計を並列取得し、voteStatisticsMap をページデータに追加
src/routes/workbooks/[slug]/+page.svelte RelativeEvaluationBadge をグレードアイコンに重ねて表示(条件付き)
src/features/votes/services/vote_statistics.ts getVoteGradeStatisticsForTaskIds を追加して絞り込み取得を実装
src/features/votes/services/vote_statistics.test.ts getVoteGradeStatisticsForTaskIds のユニットテストを追加

Comment thread src/features/votes/services/vote_statistics.ts
…sticsForTaskIds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@river0525
Copy link
Copy Markdown
Collaborator Author

@KATO-Hiro
AIによるレビューには対応済みです。
ご確認よろしくお願いいたします。

Copy link
Copy Markdown
Collaborator

@KATO-Hiro KATO-Hiro left a comment

Choose a reason for hiding this comment

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

@river0525
プルリクエスト作成ありがとうございます

LGTMです

マージします

@KATO-Hiro KATO-Hiro merged commit 77ca3d4 into staging May 25, 2026
3 checks passed
@KATO-Hiro KATO-Hiro deleted the feature/#3582-workbook-diff-icon branch May 25, 2026 13:37
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] 問題集の詳細ページで管理者と投票結果の差分を表すアイコンを表示できるようにしましょう

3 participants