Skip to content

feat: show ±0 badge when vote median matches official grade#3571

Open
river0525 wants to merge 10 commits into
stagingfrom
feature/zero-diff-badge
Open

feat: show ±0 badge when vote median matches official grade#3571
river0525 wants to merge 10 commits into
stagingfrom
feature/zero-diff-badge

Conversation

@river0525
Copy link
Copy Markdown
Collaborator

@river0525 river0525 commented May 21, 2026

Summary

  • getRelativeEvaluationLabel(0)'' を返していたのを '±0' に変更し、diff=0 でもバッジが表示されるようにした
  • getRelativeEvaluationBadgeColorClass(0) にグリーン (bg-green-400/500) を追加
  • getRelativeEvaluationTooltipText('±0') に「ユーザは「ふつう」と評価」を追加
  • getRelativeEvaluationColorClass(0) を gray → green に統一
  • RelativeEvaluationBadge.svelte は変更なし({#if label}'±0' を truthy として扱うため)
  • seed.ts にデモデータ追加(APG4bPython_co, Q8)

Test plan

  • pnpm test:unit src/features/votes/utils/relative_evaluation.test.ts — 38 tests passed
  • diff=0 タスクで ±0 バッジが右上に表示されることを目視確認済み
  • ツールチップに「ユーザは「ふつう」と評価」が表示されることを確認済み
  • E2E テストで既存の投票フローにリグレッションがないことを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • 投票中央値と運営グレードが一致する場合に、右上へ緑色の「±0」バッジを表示する視覚指標を追加。
  • Documentation

    • 実装計画と設計仕様を追加し、表示・ツールチップ・アクセシビリティ挙動を明記。
  • Tests

    • ±0 ケースのラベル・色・ツールチップ期待値を単体テストで追加・更新。
  • Chores

    • デモ用の投票統計データをシードに追加。

river0525 and others added 8 commits May 21, 2026 00:15
Update badge and text color for the neutral case (diff===0) from gray/green-500/600
to consistent green-400/500 shades matching existing sky/orange badge conventions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
"zero → gray" was incorrect after the green color change; update to "zero → green".

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

coderabbitai Bot commented May 21, 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: 4e0ef168-d2ef-409b-9393-151d23fb2f06

📥 Commits

Reviewing files that changed from the base of the PR and between f564293 and 5e57a70.

📒 Files selected for processing (2)
  • docs/superpowers/plans/2026-05-20-zero-diff-badge.md
  • docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md

📝 Walkthrough

Walkthrough

diff=0(投票中央値と運営グレード一致)のときに ±0 バッジを表示する機能を完成。仕様→実装→テスト→デモデータまで統合的に実装。色表現を gray から green に変更し、ラベル表示を空文字から ±0 へ更新。

Changes

Zero-Diff Badge Implementation

Layer / File(s) Summary
Design Specification
docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md
diff=0 時の ±0 バッジ表示仕様を定義。ラベル、色、ツールチップ、影響範囲(バッジ表示箇所4件)、テスト方針を一式記載。
Implementation Plan and Lessons
docs/superpowers/plans/2026-05-20-zero-diff-badge.md
実装計画をタスク形式で整理。対象ファイル、テスト更新手順、追加変更を列挙。Docker 環境の pnpm シンボリックリンク欠損問題と TSDoc 陳腐化に関する教訓を記載。
Core Utility Functions
src/features/votes/utils/relative_evaluation.ts
getRelativeEvaluationLabel を diff=0 時に ±0 返却へ変更。getRelativeEvaluationTooltipText に ±0 ケース追加(「ふつう」説明)。getRelativeEvaluationColorClassgetRelativeEvaluationBadgeColorClass の diff=0 時の色を gray→green に、バッジを空文字→green 返却へ更新。
Unit Tests
src/features/votes/utils/relative_evaluation.test.ts
相対評価ユーティリティの期待値を更新。ラベル ('' → ±0)、ツールチップ (±0 → ふつう説明)、色クラス (gray → green)、バッジ (空文字 → green) の新規・変更テスト。
Demo Data Seeding
prisma/seed.ts
VOTE_STATS_DEMO_DATAaddVoteStatisticsDemoData() を追加。prisma.votedGradeStatistics.upsert で taskId 単位のデモレコード登録。main()addAnswers() 後に呼び出し。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • KATO-Hiro

Poem

グレーは緑に変わりて輝く 🟢
差なしの場所に ±0 の印
仕様、実装、テスト、データ並べて
中立がひとつ、声をあげる
小さな改良、大きな整合性

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% 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 Pull request title clearly summarizes the main change: displaying a ±0 badge when vote median matches official grade, which is the primary objective across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/zero-diff-badge

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.

Caution

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

⚠️ Outside diff range comments (2)
docs/superpowers/plans/2026-05-20-zero-diff-badge.md (1)

1-79: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

フォーマット修正が必要です。

  • Prettier チェック警告(パイプライン検出)
  • コードブロック前後に空行が必要(MD031、lines 66-69)

修正手順:

# Prettier でフォーマット
pnpm format:write docs/superpowers/plans/2026-05-20-zero-diff-badge.md

Line 65 と 70 にも空行を追加してください(MD031 対応)。

🤖 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 `@docs/superpowers/plans/2026-05-20-zero-diff-badge.md` around lines 1 - 79,
The markdown has Prettier/MD031 formatting issues around the shell code block
under the "Docker node_modules シンボリックリンク欠損問題" section beneath the "# ±0
相対評価バッジ表示 Implementation Plan" heading; fix by adding an empty line before and
after the fenced shell code block (the ```shell ... ``` block) and then run the
formatter command pnpm format:write to reformat the file so Prettier passes.
docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md (1)

1-58: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Prettier フォーマット修正が必要です。

パイプラインで Prettier チェックが警告を出しています。

以下を実行してフォーマットを修正してください:

pnpm format:write docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md
🤖 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 `@docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md` around lines 1 -
58, Run the project's Prettier formatter to fix formatting in the markdown spec
titled "# ±0 相対評価バッジ表示機能 — 設計仕様" by executing the formatter command (pnpm
format:write), then stage and commit the changes so the pipeline Prettier check
passes; ensure your local Prettier configuration is used and re-run the CI
check.
🤖 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.

Outside diff comments:
In `@docs/superpowers/plans/2026-05-20-zero-diff-badge.md`:
- Around line 1-79: The markdown has Prettier/MD031 formatting issues around the
shell code block under the "Docker node_modules シンボリックリンク欠損問題" section beneath
the "# ±0 相対評価バッジ表示 Implementation Plan" heading; fix by adding an empty line
before and after the fenced shell code block (the ```shell ... ``` block) and
then run the formatter command pnpm format:write to reformat the file so
Prettier passes.

In `@docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md`:
- Around line 1-58: Run the project's Prettier formatter to fix formatting in
the markdown spec titled "# ±0 相対評価バッジ表示機能 — 設計仕様" by executing the formatter
command (pnpm format:write), then stage and commit the changes so the pipeline
Prettier check passes; ensure your local Prettier configuration is used and
re-run the CI check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d0dd1f9a-2d18-47d3-b07b-53e056b52bc7

📥 Commits

Reviewing files that changed from the base of the PR and between e7133bc and f564293.

📒 Files selected for processing (5)
  • docs/superpowers/plans/2026-05-20-zero-diff-badge.md
  • docs/superpowers/specs/2026-05-20-zero-diff-badge-design.md
  • prisma/seed.ts
  • src/features/votes/utils/relative_evaluation.test.ts
  • src/features/votes/utils/relative_evaluation.ts

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.

2 participants