Skip to content

feat(courses): add GET /api/v1/admin/courses/:id/enrollment-trends endpoint (#391) - #459

Merged
DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
ZacLou:feat/course-enrollment-trends-issue-391
Sep 2, 2026
Merged

feat(courses): add GET /api/v1/admin/courses/:id/enrollment-trends endpoint (#391)#459
DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
ZacLou:feat/course-enrollment-trends-issue-391

Conversation

@ZacLou

@ZacLou ZacLou commented Sep 2, 2026

Copy link
Copy Markdown

Summary

Adds — an admin endpoint that returns enrollment trends for a specific course over time.

Features

  • Configurable time range: , , or (default: )
  • Configurable granularity: , , or (default: )
  • Returns a time series of enrollment counts within the selected range
  • Returns total enrollments in the selected range
  • Cached for 1 hour (matching getCourseAnalytics's TTL)

Implementation

  • Follows the existing controller → service → routes → types module pattern
  • Uses date_trunc() for time bucketing (same approach as getCourseAnalytics)
  • zod validation for query params (range and granularity enums)
  • authGuard + adminGuard middleware (admin-only)
  • NotFoundError for non-existent courses (404)
  • sql.raw() for safe interpolation of validated enum values

Closes #391

…dpoint (ChainLearnOfficial#391)

Admin endpoint returning enrollment trends for a course over time with
configurable range (7d/30d/90d) and granularity (daily/weekly/monthly).
Cached for 1 hour. Returns time series data with enrollment counts and
total enrollments in the selected range.

Follows the established controller→service→routes→types pattern with
zod validation and authGuard+adminGuard middleware.

Closes ChainLearnOfficial#391
@DeFiVC
DeFiVC merged commit d29320e into ChainLearnOfficial:main Sep 2, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3. Add GET /api/v1/courses/:id/enrollment-trends endpoint (admin)

2 participants