Skip to content

Bosu - Finish Analytics Dashboard Integration - Backend - #2349

Open
BosuBose132 wants to merge 6 commits into
developmentfrom
Bosu-PR1917-Analytics-Backend-Fix
Open

Bosu - Finish Analytics Dashboard Integration - Backend#2349
BosuBose132 wants to merge 6 commits into
developmentfrom
Bosu-PR1917-Analytics-Backend-Fix

Conversation

@BosuBose132

Copy link
Copy Markdown
Contributor

Description

This PR completes and takes over the unfinished Analytics Dashboard backend work from PR #1917.

Original PR:
#1917

Related Frontend:
#4482

Main Changes

  • Added and finalized Analytics Overview backend integration.
  • Added student-level analytics support.
  • Kept analytics GET endpoints read-only.
  • Added explicit POST refresh endpoint for on-demand metric recalculation/persistence.
  • Added scheduled refresh support for StudentMetrics.
  • Added validation for malformed analytics source data.
  • Prevented NaN, Infinity, null, and malformed response values from corrupting analytics calculations.
  • Added student, class, and date-range filtering.
  • Added daily time-series data for:
    • Average score
    • Time spent
    • Engagement rate
  • Added student and class filter option data to the overview response.
  • Preserved empty filtered results instead of falling back to global analytics.

Endpoints

Overview

GET /api/analytics/overview

Optional query parameters:

  • studentId
  • classId
  • startDate
  • endDate

Student Metrics

GET /api/analytics/student/:studentId

Explicit Refresh

POST /api/analytics/student/:studentId/refresh

Testing

  • Focused Analytics tests: 31 passed
  • Full backend test suite: 152 suites passed
  • 2,199 tests passed
  • 6 skipped
  • 19 todo
  • Build passed
  • ESLint: 0 errors
  • git diff --check passed

Manual Verification

Verified locally that:

  • Overview endpoint returns scalar analytics metrics.
  • Student/class/date filters work.
  • Filtered empty results return null averages and empty chart data.
  • Student GET remains read-only.
  • POST refresh performs persistence.
  • Time-series data is returned when matching FormResponse data exists.
Screenshot 2026-09-11 at 5 16 58 PM

Important Local Testing Note

npm start runs the compiled backend from dist.

After backend source changes, run:

npm run build
npm start

sphurthy and others added 6 commits November 21, 2025 12:38
…docs

Addresses PR review: GET /api/analytics/student/:studentId was growing the
studentMetrics collection on each call. Without a unique index the
findOneAndUpdate upsert could insert duplicate documents for the same
student. A unique index guarantees exactly one metrics doc per student, so
repeated GET requests update in place instead of adding rows.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tics-integration-backend

# Conflicts:
#	package-lock.json
#	src/startup/routes.js
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants