Feat/vote dropdown relative label#3447
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughグレード選択ドロップダウンのレイアウトを調整し、確定済タスクの各選択肢に差分(-2〜+2)に基づく日本語の相対評価ラベルと色付けを追加。相対評価ユーティリティ群と対応テストを導入し、バッジ表示ロジックを簡素化した。 Changes
Sequence Diagram(s)(該当なし) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
投票ドロップダウン内で、公式グレードとの差分に応じた相対評価ラベル(日本語)を表示できるようにするPRです。
Changes:
- 相対評価の差分(diff)を日本語ラベルへ変換するユーティリティ関数を追加
- 追加関数のテストケースを追加
- 投票ドロップダウンの各グレード行に相対評価ラベル表示とレイアウト調整を追加
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/features/votes/utils/relative_evaluation.ts | diff→日本語ラベル変換関数を追加 |
| src/features/votes/utils/relative_evaluation.test.ts | 新規ユーティリティ関数のテストを追加 |
| src/features/votes/components/VotableGrade.svelte | ドロップダウン項目に相対評価ラベル列を追加し、幅/レイアウトを調整 |
| * Returns an empty string when the diff falls outside the expected ±2 range. | ||
| * | ||
| * | diff | label | | ||
| * | ---- | ------------ | | ||
| * | ≤ −3 | `''` | | ||
| * | −2 | `易しい` | | ||
| * | −1 | `やや易しい` | | ||
| * | 0 | `ふつう` | | ||
| * | +1 | `やや難しい` | | ||
| * | +2 | `難しい` | | ||
| * | ≥ +3 | `''` | | ||
| * | ||
| * @param diff - A grade difference (e.g., from {@link calcGradeDiff}). | ||
| * @returns The Japanese label string, or `''` if out of expected range. | ||
| */ | ||
| export function getRelativeEvaluationJapaneseLabel(diff: number): string { | ||
| switch (diff) { | ||
| case -2: | ||
| return '易しい'; | ||
| case -1: | ||
| return 'やや易しい'; | ||
| case 0: | ||
| return 'ふつう'; | ||
| case 1: | ||
| return 'やや難しい'; | ||
| case 2: | ||
| return '難しい'; | ||
| default: | ||
| return ''; | ||
| } |
There was a problem hiding this comment.
getRelativeEvaluationJapaneseLabel returns an empty string for diff <= -3 / diff >= 3, but calcGradeDiff can legitimately produce those values (e.g., Q11↔D6 is ±16) and this function is used in VotableGrade for every grade option. As a result, most dropdown items may show no relative label even though the existing relative-evaluation logic clamps to the extremes (e.g., getRelativeEvaluationLabel(16) => ++). Consider clamping here as well (e.g., treat diff <= -2 as '易しい' and diff >= 2 as '難しい') or derive the Japanese label from getRelativeEvaluationLabel(diff) to keep behavior consistent.
| * Returns an empty string when the diff falls outside the expected ±2 range. | |
| * | |
| * | diff | label | | |
| * | ---- | ------------ | | |
| * | ≤ −3 | `''` | | |
| * | −2 | `易しい` | | |
| * | −1 | `やや易しい` | | |
| * | 0 | `ふつう` | | |
| * | +1 | `やや難しい` | | |
| * | +2 | `難しい` | | |
| * | ≥ +3 | `''` | | |
| * | |
| * @param diff - A grade difference (e.g., from {@link calcGradeDiff}). | |
| * @returns The Japanese label string, or `''` if out of expected range. | |
| */ | |
| export function getRelativeEvaluationJapaneseLabel(diff: number): string { | |
| switch (diff) { | |
| case -2: | |
| return '易しい'; | |
| case -1: | |
| return 'やや易しい'; | |
| case 0: | |
| return 'ふつう'; | |
| case 1: | |
| return 'やや難しい'; | |
| case 2: | |
| return '難しい'; | |
| default: | |
| return ''; | |
| } | |
| * Values outside the central ±1 range are clamped to the nearest extreme label. | |
| * | |
| * | diff | label | | |
| * | ------ | ------------ | | |
| * | ≤ −2 | `易しい` | | |
| * | −1 | `やや易しい` | | |
| * | 0 | `ふつう` | | |
| * | +1 | `やや難しい` | | |
| * | ≥ +2 | `難しい` | | |
| * | |
| * @param diff - A grade difference (e.g., from {@link calcGradeDiff}). | |
| * @returns The Japanese label string. | |
| */ | |
| export function getRelativeEvaluationJapaneseLabel(diff: number): string { | |
| if (diff <= -2) { | |
| return '易しい'; | |
| } | |
| if (diff === -1) { | |
| return 'やや易しい'; | |
| } | |
| if (diff === 0) { | |
| return 'ふつう'; | |
| } | |
| if (diff === 1) { | |
| return 'やや難しい'; | |
| } | |
| return '難しい'; |
There was a problem hiding this comment.
DBグレードと中央値の差が±3より大きいとき、相対ラベルが付けられていない件の話ですね。
これに関しては意図的で、運営とユーザーのグレード乖離が±2を超えることは想定していないためです。
もちろん、投票自体は可能です。
@KATO-Hiro この件に関してはこのままでよろしいでしょうか?
There was a problem hiding this comment.
確かに正規分布にしたがうと仮定して±2σ相当と考えれば、大半のケースはカバーできていそうです。
このまま進めましょう。
実際の投票状況を確認して、必要に応じて軌道修正する方向で良さそうです。
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/features/votes/components/VotableGrade.svelte`:
- Around line 219-231: The template in VotableGrade.svelte embeds nested ternary
color-class logic for diff; extract that mapping into a shared helper (e.g., add
getRelativeEvaluationColorClass(diff) in relative_evaluation.ts or utils) and
replace the inline ternary in VotableGrade.svelte (where calcGradeDiff and
getRelativeEvaluationJapaneseLabel are used) with a call to that helper; also
update RelativeEvaluationBadge to consume the same helper so both components use
one source of truth for color classes.
🪄 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: 06daf2e3-21cc-4a55-bc83-ebc78d9dc64e
📒 Files selected for processing (1)
src/features/votes/components/VotableGrade.svelte
…badge Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
KATO-Hiro
left a comment
There was a problem hiding this comment.
ありがとうございます
LGTMです
マージします
投票ドロップダウンの相対評価ラベルの実装です。
Summary by CodeRabbit
新機能
Style
Refactor
Tests