Conversation
|
Caution Review failedThe pull request is closed. WalkthroughAdds a new instructor-only GET endpoint to list certificates for courses authored by the authenticated user. Implements controller logic to query courses by authorId, fetch related certificates with selected populations, sort by creation date, and handle auth, empty results, and errors. Updates routing to wire the endpoint with middlewares. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as Instructor (Client)
participant R as Router: /certificates
participant A as isAuthenticated
participant AR as authorizeRoles("instructor")
participant C as certificate.controller.getCertificatesByInstructor
participant M1 as Course Model
participant M2 as Certificate Model
U->>R: GET /instructor/courses
R->>A: Verify session/JWT
A-->>R: OK or 401
alt Unauthenticated
R-->>U: 401 Unauthorized
else Authenticated
R->>AR: Check role = instructor
AR-->>R: OK or 403
alt Not instructor
R-->>U: 403 Forbidden
else Instructor
R->>C: getCertificatesByInstructor(req, res)
C->>M1: find({ authorId: req.user._id }).select("_id")
M1-->>C: courseIds
alt No courses
C-->>U: 200 []
else Has courses
C->>M2: find({ course: { $in: courseIds }})<br/>.populate(user, course)<br/>.sort(-createdAt)
M2-->>C: certificates
C-->>U: 200 certificates
end
end
end
rect rgba(200, 230, 255, 0.3)
note right of C: New controller flow to aggregate certificates by instructor-owned courses
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes Possibly related PRs
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (2)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Summary by CodeRabbit