feat(dashboard): add instructor analytics dashboard (#562)#765
Merged
RUKAYAT-CODER merged 1 commit intoJun 1, 2026
Merged
Conversation
|
@CNduka001 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
Thank you for contributing to the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR #562 feat(dashboard): Instructor analytics dashboard
What changed
GET /dashboard/instructors/:instructorIdendpoint insrc/dashboard/dashboard.controller.ts.getInstructorDashboard(instructorId)and supporting helpers insrc/dashboard/dashboard.service.ts:getInstructorRevenueBreakdown(instructorId)— revenue by currency, by course, and by payment method (completed payments only).calculateEnrollmentTrends(courses, days=30)— daily enrollment buckets for the last 30 days (configurable).calculateCompletionRate(courses)— overall and monthly completion rates (6-month window).getInstructorVideoWatchTime(courses)— aggregates recordedvideo/watchevents fromanalytics_eventsand falls back to progress-based estimates when events are absent.AnalyticsEventrepository insrc/dashboard/dashboard.module.ts.src/dashboard/dashboard.service.spec.tsto validate instructor dashboard generation and mocked query builders for payments and analytics.API
GET /dashboard/instructors/:instructorId
Response (example):
Testing
Unit tests were added/updated in
src/dashboard/dashboard.service.spec.ts. To run the tests locally (project must have dev deps installed):npm ci npm test -- src/dashboard/dashboard.service.spec.ts --runInBandHow to smoke-test the endpoint locally
Start the application (depending on your local start script):
Then hit the endpoint (replace
:instructorIdwith a real instructor UUID):curl -H "Authorization: Bearer <token>" http://localhost:3000/dashboard/instructors/:instructorIdNotes for reviewers
analytics_eventsforcategory = 'video'andaction = 'watch'events with a numericvaluerepresenting watched seconds. If no events exist for a course, the service estimates watch time from enrollmentprogressand lessondurationSeconds.PaymentStatus.COMPLETEDand uses the existingReportingServicefor monthly recognition where appropriate.payments->courseand group by currency/course/method. If you anticipate large datasets, we should consider adding batched endpoints or pre-aggregated views.DashboardServiceand inherits any guards ondashboardroutes; consider restrictingGET /dashboard/instructors/:instructorIdto instructors or admins if desired.Follow-ups
byCourserevenue lists when an instructor has many coursesFiles touched (high-level)
src/dashboard/dashboard.controller.tssrc/dashboard/dashboard.service.tssrc/dashboard/dashboard.module.tssrc/dashboard/dashboard.service.spec.tsReviewer checklist
paymentsandanalytics_eventsqueries (performance)analytics_eventscontainsvideo/watchevents in expected shape before enabling the UICloses #562