refactor: use inArray for enrollment count query#14
Open
okeolaolatun23-glitch wants to merge 2 commits into
Conversation
DeFiVC
reviewed
Jun 20, 2026
DeFiVC
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution! The code change itself is correct and addresses issue #1 perfectly — using inArray instead of eq with only the first course ID is exactly what's needed.
However, this PR currently cannot be merged due to two issues:
1. Merge Conflicts
The branch has conflicts with src/modules/courses/course.service.ts. Main has been updated with PR #17 which added withLock imports and other changes. You'll need to rebase on the latest main:
git fetch origin
git rebase origin/main
# resolve conflicts in src/modules/courses/course.service.ts
git add .
git rebase --continue2. CI Failure
The "Lint & Typecheck" job failed because package-lock.json is missing from your branch. It was added to main after your branch was created. The rebase above will fix this.
Please rebase on latest main, resolve any conflicts, and push — I'll re-review once CI passes. 👍
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.
Closes #1
PR Documentation
Title
Fix course list enrollment counts across paginated results
Summary
listCoursesinsrc/modules/courses/course.service.tswas only counting enrollments for the first course on the page. As a result, the course catalog showed the correctenrolledCountfor the first item and0for every other course in the same response.Change Made
inArrayfromdrizzle-orm.eq(enrollments.courseId, courseIds[0])toinArray(enrollments.courseId, courseIds).Impact
enrolledCountvalue is now accurate for all listed courses, not just the first one.Verification
Manual verification steps:
GET /api/courses?page=1&limit=10.enrolledCount: 5enrolledCount: 3enrolledCount: 0