fix(#314): enforce maximum difficulty cap in recommendation fallback paths#339
Conversation
|
@Sujini-kudupudi is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Sujini-kudupudi can you please fix the failing CI test |
|
@Ayush-Patel-56 Could you please check it once? |
|
@Sujini-kudupudi its still failing |
|
@Sujini-kudupudi It looks like the CI pipeline is still failing on the |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
jakharmonika364
left a comment
There was a problem hiding this comment.
Also this PR has a bunch of unrelated stuff mixed in (resend bump, the issues.ts Octokit rewrite, as any casts in supabase/server.ts) - can we split those out? Makes this harder to review than it needs to be.
The filterAndRank fix itself looks right.
| const { data: profile } = await service | ||
| .from('profiles') | ||
| .select('level') | ||
| .eq('user_id', user.id) | ||
| .single(); |
There was a problem hiding this comment.
profiles has no user_id column, it's id (every other lookup in the codebase uses .eq('id', user.id)). This silently fails and userLevel defaults to 0 always - error isn't checked. Should be .eq('id', user.id).
Summary
This PR fixes an issue where users could receive issues beyond their allowed difficulty cap (e.g. Level 0 receiving Medium or Hard issues) via fallback paths when the difficulty pool runs dry or when skipping an issue.
Type of Change
Related Issue
Closes #314
What was changed?
filterAndRankinsrc/lib/pipeline/recommend.tsto strictly cap the fallback difficulty based on the user's level (e.g., Level 0 allows['E']only).skipRecommendationaction insrc/app/actions/recommendations.tsto fetch the user'slevelfrom theprofilestable.levelintopickReplacementto calculate allowed difficulties and applied.in('difficulty', allowedDifficulties)during the broad pool fallback query.src/lib/pipeline/recommend.test.tsto correctly assert that the fallback mechanism respects the max difficulty cap.Screenshots
N/A
Checklist
npm run dev)