Naalya Handbook
School features

Analytics

Read-only counts behind one controller. Each route hands off to the service that owns the data, and every count runs on a school-scoped repository.

One controller at analytics/* answers every analytics screen. It does no counting itself: each route calls the service that owns the data. Nothing is cached, so every request counts live rows.

Routes

Every route needs read on analytics, except audit logs. A route with a /campus/:campusId twin filters to that campus.

RouteCampus twinExtra permissionCalls
students, staff, guardiansYesNoneEach profile service's getAnalytics
guestsNoNoneGuestService.getAnalytics
classesYesNoneClassService.getAnalytics
classes/:classIdNoRead on that class (checked in the service)getClassDetailAnalytics
applicationsYesNoneAdmissionApplicationService.getAnalytics
enquiries, enquiries/by-period, enquiries/by-staffNoNoneEnquiry getStats, getStatsByPeriod, getStatsByStaff
academicsYesRead on gradeAcademicAnalyticsService
teachingYesRead on scheme_of_workTeachingAnalyticsService
audit-logsNoRead on audit_log instead of analyticsAuditLogService.getAnalytics

Two rules for a new count

  1. Build it on a scoped repository. Use this.someRepository.createQueryBuilder(...), never dataSource.query. Then the school_id filter applies to every COUNT as it does to every list. The usual shape: Promise.all over several counts, COUNT(DISTINCT ...), explicit deleted_at IS NULL, and an inner join to campus_x_academic_year with is_current = true when "this year" matters.
  2. Reuse the date window. Extend AnalyticsTimelineQueryDto (optional startDate, endDate) and call resolveAnalyticsDateRange. It defaults to the last 30 days and returns endDatePlusOne, so queries use [start, end + 1). When start and end fall on the same day, timelines bucket by hour. Return the shared shapes such as TimelineDataPointDto { date, count }.

The academics and teaching routes use a term instead of a date window; see Term-based counts.

What each count covers

The trap on every route: only some fields use the date window. The rest cover all time, the current year, or the calendar month.

RouteUses the date windowIgnores the window
People (all four)dailyTimelinetotal, active, suspended, newThisMonth (calendar month), recent (newest 5)
ClassesenrollmentTimelineStream and enrolment counts, byLevel, byGradeLevel, gradeTimeline (current year only)
ApplicationsdailyTimelinetotal, byStatus
Enquiriestotal, unassignedCount, averageResolutionTimeSeconds, byStatus, byPriority, dailyTimelinenewThisMonth, recent
Audit logsEverythingNothing

An unknown campus or year id is never an error. The response is 200 with zeros and empty lists.

Term-based counts

academics and teaching take AnalyticsTermQueryDto: optional academicYearId and term (1 to 3). TermPeriodService.resolve picks the period:

Year. The given id if it exists, otherwise the current year, otherwise the highest order. No year at all returns the empty shape (period null, zeros).

Term. The given term, otherwise the highest current term, otherwise 1. A campus route keeps only that campus's terms.

Previous term. The one before it; term 1 compares with the last term of the previous year.

term arrives as a string, because the pipe does not transform it; the service runs Number(query.term).

Academics turns marks into percents (18 of 20 is 90), skipping max_score 0 and deleted rows. It returns averagePercent and previousAveragePercent, counts graded students, grades and subjects, bySubject, byGradeLevel, bands, and a termTrend across the year. Report cards are counted by status; released counts rows with released_at set, on top of their status. For CBT, the average and passRate use graded attempts only.

Teaching counts lesson plans in the term. done is published plus approved. byWeek and bySubject (furthest behind first) break that down. Schemes count as approved, in review (a submitted revision exists) or draft.

Two lists only appear for managers, and are left out silently otherwise:

ListNeeds
topStudents, needsAttention (at least 3 subjects, max 10)Approve on report_card for that campus, or the school
byTeacherApprove on lesson_plan or scheme_of_work

In the Education Hub

ScreenPathWho can open it
School analytics/staff-hub/school/analyticsRead on analytics or audit_log
Campus analytics/staff-hub/campus/$campusId/analyticsRead on analytics

Both use AnalyticsLayout, OverviewCards and AreaPage. useVisibleAreas decides which areas show:

AreaAlso needsCampus hub
AcademicsRead on gradeShown
TeachingRead on scheme_of_work and the lesson-planning flagShown
AdmissionsThe admissions flagShown
EnquiriesThe admissions flagHidden
Guests, audit logsAudit logs: read on audit_logHidden

An area the viewer cannot open redirects to the overview.

Screen sums to know before you trust a number:

  • "New this period" on people cards is the sum of dailyTimeline, not newThisMonth.
  • "Awaiting decision" is submitted from byStatus, so it covers all time, not the window.
  • Enquiry resolution rate on the tab is completed over total. The staff table uses the service's resolutionRate (resolved_at over assigned), a different measure.
  • "Cannot sign in" on staff and guardian tiles is screen wording. The service only counts suspended profiles; it does not check sign-in.
  • Released report cards sit beside the status total, not inside it.

Where to go next

On this page