Bug:Pros & Cons Challenge is Completely Non-Functional (Missing Routes) - #454
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe server now centralizes coach route registration and adds functional pros-and-cons topic and submission endpoints. Coach handlers use the authenticated context user ID, and point updates accept both string and object identifier values. ChangesCoach routes and challenge flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change enables the Pros & Cons Challenge to fetch topics and submit evaluated responses while preserving authenticated coach routing. No merge-blocking risk is identified. Sequence Diagram(s)sequenceDiagram
participant CoachClient
participant GetProsConsTopic
participant GenerateDebateTopic
participant SubmitProsCons
participant EvaluateProsCons
participant UpdateUserPoints
CoachClient->>GetProsConsTopic: request topic
GetProsConsTopic->>GenerateDebateTopic: generate topic for skill level
GenerateDebateTopic-->>GetProsConsTopic: return topic
GetProsConsTopic-->>CoachClient: return topic
CoachClient->>SubmitProsCons: submit topic, pros, and cons
SubmitProsCons->>EvaluateProsCons: evaluate validated entries
EvaluateProsCons-->>SubmitProsCons: return evaluation
SubmitProsCons->>UpdateUserPoints: update points for context userID
SubmitProsCons-->>CoachClient: return evaluation
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
|
@Ri1tik let me know if any changes needed. |
Addressed Issues:
Fixes #452
Screenshots/Recordings:
bug_resolved.mp4
Additional Notes:
This PR resolves the issue where the Pros & Cons Challenge was completely non-functional. Previously, the backend endpoints for generating challenge topics and submitting evaluations were missing from the router registration, returning 404 errors. In addition, this PR implements the route handlers, adds input validation, and fixes the user ID extraction so earned points are properly awarded to the user's account.
Added coach.go:12-20 to group and register all coach-related endpoints under
/coach:GET /coach/strengthen-argument/weak-statementPOST /coach/strengthen-argument/evaluateGET /coach/pros-cons/topicPOST /coach/pros-cons/submitroutes.SetupCoachRoutes(auth).Implemented Pros & Cons Route Handlers (
backend/routes/coach.go)beginner,intermediate,advanced) based on their authenticated profile rating."beginner"if rating is not present or non-float.services.GenerateDebateTopic(skillLevel)to generate a topic.services.EvaluateProsCons(topic, pros, cons).services.UpdateUserPoints.Fixed User Points Update (
backend/routes/coach.go&backend/services/coach.go)c.GetString("user_id")withuserID, _ := c.Get("userID")in bothEvaluateStrengthenedArgumentandSubmitProsCons.userID interface{}to properly support MongoDBprimitive.ObjectIDextracted from the auth middleware context.AI Usage Disclosure:
Checklist
Summary by CodeRabbit
New Features
Bug Fixes