feat(question): add DSA study-plan scheduler endpoint - #2306
Conversation
POST /api/question/study-plan distributes a list of problems across N days using difficulty-weighted LPT scheduling so day loads stay balanced. Core is a pure, unit-tested buildStudyPlan util; no new dependency. Closes Canopus-Labs#2305
|
Thank you for submitting your pull request, @vedant7007! 🙌 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAdds a deterministic, difficulty-weighted study-plan scheduler. The new ChangesStudy plan scheduling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: 🔵 Low · up to The PR adds an authenticated, rate-limited study-plan endpoint that performs bounded in-process scheduling. The change is mergeable, with explicit owner awareness that the new API surface introduces a limited compute and availability exposure despite input limits and access controls. Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Client
participant questionRoutes
participant buildStudyPlanHandler
participant buildStudyPlan
Client->>questionRoutes: POST /api/question/study-plan
questionRoutes->>buildStudyPlanHandler: Forward request
buildStudyPlanHandler->>buildStudyPlan: Pass problems and days
buildStudyPlan-->>buildStudyPlanHandler: Return plan and totalLoad
buildStudyPlanHandler-->>Client: Return study-plan response
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 Biome (2.5.8)backend/tests/studyPlanScheduler.unit.test.jsFile contains syntax errors that prevent linting: Line 1: Illegal use of an import declaration outside of a module; Line 2: Illegal use of an import declaration outside of a module 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 |
What & why
Closes #2305.
Turns a practice sheet into a "prep in N days" plan: given a list of problems and a target number of days, it produces a balanced day-by-day schedule.
Changes
backend/utils/studyPlanScheduler.js(new, pure, CommonJS) —buildStudyPlan(problems, days)weights problems by difficulty (easy=1, medium=2, hard=3; unknown/missing→medium viaproblemWeight) and distributes them acrossdaysbuckets with difficulty-weighted LPT scheduling (assign each, heaviest-first, to the least-loaded day). Returns{ plan: [{ day, problems, load }], totalLoad, days }. Deterministic; guards invalid input.questionController.js—buildStudyPlanHandlerwith inline validation (non-empty array, ≤1000 problems, integer days 1–365), mirroring the existingatsMatchstyle.questionRoutes.js—POST /api/question/study-plan(auth + rate-limit already applied globally).No new dependency; no
package.json/lockfile changes.Testing
backend/tests/studyPlanScheduler.unit.test.js— 11 vitest cases (weights, load balancing, exactly-once placement, empty days, default difficulty, determinism, input guards).vitest run→ 207 passed (18 files).Contributing as part of Elite Coders Summer of Code (ECSoC 2026).
Adds an authenticated
POST /api/question/study-planendpoint.1, medium2, hard3.daysexceeds the problem count.