[feat] 問題集の詳細ページのグレードアイコンから投票できるようにする#3589
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 (2)
📝 WalkthroughWalkthrough投票入力を Zod スキーマで検証し、検証済みデータを vote アクションに渡すよう改築。workbook ページに Changes投票検証スキーマと vote アクション改築
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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.
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 41-44: The page is loading global vote stats via
getVoteGradeStatistics(), causing high payload; change to fetch only stats for
tasks in this workbook by replacing the call with a new service that accepts
task IDs (e.g., getVoteGradeStatisticsByTaskIds). Collect the task IDs from
workBook.workBookTasks (map to id strings), call
getVoteGradeStatisticsByTaskIds(taskIds) where getVoteGradeStatistics() was
used, and update imports to use the new function (implement
getVoteGradeStatisticsByTaskIds in
src/features/votes/services/vote_statistics.ts to query votedGradeStatistics
where taskId in taskIds and return a map keyed by taskId).
🪄 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: 1f7da413-3c8e-4a39-8a39-d26527c8ffe1
📒 Files selected for processing (2)
src/routes/workbooks/[slug]/+page.server.tssrc/routes/workbooks/[slug]/+page.svelte
|
@KATO-Hiro |
|
@river0525 先ほど、#3588 をマージいたしました |
Replace GradeLabel with VotableGrade so users can vote directly from the grade icon on the workbook detail page. Fetches vote statistics in parallel with task results and adds the voteAbsoluteGrade form action. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38b1e67 to
a05606e
Compare
There was a problem hiding this comment.
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 61-63: The voteAbsoluteGrade action currently delegates without
Superforms+Zod validation; update +page.server.ts to perform server-side
validation with Superforms and your Zod schema before calling
voteAbsoluteGradeAction: import the Zod schema for the vote form and Superforms'
superValidate, call await superValidate(request, voteAbsoluteGradeSchema) (or
equivalent) to get validated.data, then pass that validated payload into
voteAbsoluteGradeAction (e.g., voteAbsoluteGradeAction({ request, locals, data:
validated.data })), and adjust voteAbsoluteGradeAction signature to accept and
use the validated data instead of raw request parsing.
🪄 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: 3fac380a-ba96-4524-83e0-53203b2f7eb3
📒 Files selected for processing (2)
src/routes/workbooks/[slug]/+page.server.tssrc/routes/workbooks/[slug]/+page.svelte
|
@KATO-Hiro |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/features/votes/zod/schema.ts`:
- Line 5: taskId の Zod スキーマは現在 z.string().min(1)
で空白のみが通ってしまうので、src/features/votes/zod/schema.ts の taskId 定義を
z.string().trim().min(1) に変更して前後の空白を除去し空文字を拒否するようにし、既存のバリデーションエラー処理(Zod
のエラーハンドリング)で不正入力を 400 レスポンスに返すことを確認してください。
In `@src/lib/types/auth_forms.ts`:
- Line 22: The current recursive type SchemaShape = { [key: string]: SchemaShape
} forces every node to be an object of the same shape and prevents leaf nodes
like { type: 'string' }; update SchemaShape to allow either a nested map or a
leaf descriptor (e.g., permit objects like { type: string } at leaves) so
form.shape can be typed as { username: { type: 'string' }, password: { type:
'string' } } without casts; change the definition of SchemaShape (and any uses)
to something like a union between a map and a leaf descriptor so callers (and
auth_forms.test.ts) no longer need as unknown casts.
In `@src/lib/utils/auth_forms.ts`:
- Line 167: createBaseAuthForm's fallback `shape: {}` breaks compatibility with
tests expecting a username/password schema; replace the empty fallback shape in
createBaseAuthForm with the expected schema (username and password entries with
type 'string') so the function returns a shape matching { username: { type:
'string' }, password: { type: 'string' } } when no custom shape is provided.
🪄 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: b1713abb-a947-4ce3-96e1-7f436b42a02d
📒 Files selected for processing (9)
prisma/seed.tssrc/features/votes/actions/vote_actions.tssrc/features/votes/zod/schema.tssrc/features/workbooks/stores/replenishment_workbook.test.tssrc/lib/types/auth_forms.tssrc/lib/utils/auth_forms.tssrc/routes/problems/+page.server.tssrc/routes/votes/[slug]/+page.server.tssrc/routes/workbooks/[slug]/+page.server.ts
- Add .trim() to taskId in voteAbsoluteGradeSchema to reject whitespace-only strings
- Fix SchemaShape type from recursive self-reference to Record<string, unknown> so leaf values like { type: 'string' } are representable
- Restore shape fallback in createBaseAuthForm to { username: { type: 'string' }, password: { type: 'string' } } — was emptied when recursive type was introduced
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@KATO-Hiro |
Summary
GradeLabelからVotableGradeに置き換え、クリックで投票ドロップダウンを開けるようにするisAtCoderVerifiedをページに追加し、voteAbsoluteGradeフォームアクションを追加するChanges
src/routes/workbooks/[slug]/+page.server.ts:getVoteGradeStatistics()を並列取得してvoteStatisticsMapを返すisAtCoderVerified: locals.user?.is_validated === trueを返すvoteAbsoluteGradeアクションを追加(既存のvote_actions.tsを再利用)src/routes/workbooks/[slug]/+page.svelte:GradeLabel→VotableGradeに置き換えisAtCoderVerified・voteStatisticsMapを$derivedで取得getTaskGrade関数とTaskGradeimport を削除Test plan
pnpm format && pnpm check && pnpm test:unitがすべてパスすることを確認🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
新機能
改善