Add dashboard mode to POST course/status API — return per-course, peruser completion status and attempt count#130
Conversation
…-user completion status and attempt count
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Code Review
This pull request updates the tracking content service to support extracting the tenant ID from the 'x-tenant-id' header and introduces a new dashboard-specific query path when the search filter type is set to 'dashboard'. This new path retrieves course certificates and assessment tracking attempts in parallel. The review feedback suggests improving code quality by using strict equality and removing redundant checks, renaming the misleading 'highestAttempt' property to 'attemptCount' to match the underlying SQL query, and correcting brace formatting to maintain consistency with the rest of the codebase.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if(type && type=='dashboard') | ||
| { |
There was a problem hiding this comment.
| const userStatusMap: Record<string, { status: string; highestAttempt: number }> = {}; | ||
|
|
||
| for (const userId of userIdArray) { | ||
| const key = `${courseId}_${userId}`; | ||
| const rawStatus = statusMap.get(key); | ||
| const status = | ||
| !rawStatus || rawStatus.toLowerCase() === 'enrolled' | ||
| ? 'not_started' | ||
| : rawStatus; | ||
|
|
||
| userStatusMap[userId] = { | ||
| status, | ||
| highestAttempt: attemptMap.get(key) || 0, | ||
| }; |
There was a problem hiding this comment.
The property name highestAttempt is misleading because the SQL query computes the total count of attempts (COUNT("assessmentTrackingId")) rather than finding a maximum attempt number. Additionally, the PR title explicitly states that this API should return the attempt count.
Please rename highestAttempt to attemptCount to align with the PR requirements and the actual database query logic.
| const userStatusMap: Record<string, { status: string; highestAttempt: number }> = {}; | |
| for (const userId of userIdArray) { | |
| const key = `${courseId}_${userId}`; | |
| const rawStatus = statusMap.get(key); | |
| const status = | |
| !rawStatus || rawStatus.toLowerCase() === 'enrolled' | |
| ? 'not_started' | |
| : rawStatus; | |
| userStatusMap[userId] = { | |
| status, | |
| highestAttempt: attemptMap.get(key) || 0, | |
| }; | |
| const userStatusMap: Record<string, { status: string; attemptCount: number }> = {}; | |
| for (const userId of userIdArray) { | |
| const key = courseId + '_' + userId; | |
| const rawStatus = statusMap.get(key); | |
| const status = | |
| !rawStatus || rawStatus.toLowerCase() === 'enrolled' | |
| ? 'not_started' | |
| : rawStatus; | |
| userStatusMap[userId] = { | |
| status, | |
| attemptCount: attemptMap.get(key) || 0, | |
| }; | |
| } |
| } | ||
| else | ||
| { |
…-user completion status and attempt count
|



https://prathamdigitalteam.atlassian.net/browse/PS-7130