Skip to content

Add dashboard mode to POST course/status API — return per-course, peruser completion status and attempt count#130

Merged
rushi-tekdi merged 2 commits into
tekdi:AI-assessmentfrom
rushi-tekdi:AI-Assessment
Jul 8, 2026
Merged

Add dashboard mode to POST course/status API — return per-course, peruser completion status and attempt count#130
rushi-tekdi merged 2 commits into
tekdi:AI-assessmentfrom
rushi-tekdi:AI-Assessment

Conversation

@rushi-tekdi

Copy link
Copy Markdown
Collaborator

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7d71adf-1983-455e-a904-57423fd803e0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +607 to +608
if(type && type=='dashboard')
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Use strict equality (===) and remove the redundant type && check since type === 'dashboard' is safe even if type is undefined or null. Also, format the opening brace on the same line to match the consistent coding style used throughout this file.

      if (type === 'dashboard') {

Comment on lines +638 to +651
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,
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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,
};
}

Comment on lines 663 to +665
}
else
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Format the else block with the closing and opening braces on the same line to maintain consistency with the rest of the codebase.

      } else {

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@rushi-tekdi
rushi-tekdi merged commit 6cd2bb0 into tekdi:AI-assessment Jul 8, 2026
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.

1 participant