Naalya Handbook
School features

School reports

How a monthly or termly school report is planned, written, painted and downloaded, and what its numbers count.

A school report is a set of PDFs about the school and each campus for a month or a term. It is not a learner's report card. Every route needs Feature.SCHOOL_REPORTS and starts with /api/v1/school-report.

Routes

RouteOperation idNeedsNotes
POST /runscreateSchoolReportRuncreateStarts a monthly or termly run
POST /runs/:id/retryretrySchoolReportRuncreateRe-queues failed documents. No failed documents to retry if none
GET /runslistSchoolReportRunslistWith campusId, each run keeps only that campus's documents
GET /runs/:idgetSchoolReportRunreadDrops documents for campuses you can't read
GET /documents/:id/downloaddownloadSchoolReportDocumentread on that campusA signed link valid for one hour. This document is not ready yet until it is
GET /styleslistSchoolReportStylesreadThe painting styles

Permissions are on school_report. Create and retry publish SCHOOL_REPORT_RUN_UPDATE so screens refresh.

What a run plans

MonthlyTermly, started by staffTermly, from the daily tick
PeriodOne calendar monthEarliest campus term start to the latest end, or to now with "(to date)"Same
Campus documentsEvery campusEvery campus with that term numberOnly campuses whose term has ended
School documentAlwaysAlwaysOnly once every campus has ended

ensureRun creates the run, or adopts the existing one if two callers race on the same period. Pending documents are queued; failed ones are re-queued on a manual start, or when a to-date run is being extended to the full term. Each job gets one attempt.

How a document is made

The worker (SchoolReportProcessor, concurrency 2) runs each document through:

Count. A campus document collects admissions, enrolments, structure, grades, staff and students. The school document collects enquiries, guest accounts and one summary row per campus.

Write. A model writes a summary, one block per section, headlines of up to twelve words, and a callout per fact. It times out at 120 seconds and retries once. The words are refused if they contain an em dash or ellipsis, or any number that isn't in that section's data.

Paint. Each page (a cover plus one per section) is drawn as a 1248x1760 PNG by the configured gpt-image-2 model, in the school's schoolReportStyle. A reader then checks the picture: missing or cut-off words, or an invented number, fail it. A failed page is redrawn once; a second failure fails the document.

Store. The PDF is saved and the document becomes ready. When the run is complete and this was the school document, runReady fires.

Any failure marks the document failed with the error. The daily tick doesn't retry it; staff retry from the screen.

What the numbers count

FigureCounts
Active enrolments at a momentRows active now, or now in an exit status but updated at or after that moment. There is no status history
New enrolmentsdate_enrolled inside the window
LeaversThe latest 100 in an exit status (transferred, graduated, dropped, withdrawn, suspended, revoked, expired, excluded, cancelled, rejected)
Grade averagescore / max_score * 100 for grades created in the window for that term. Pass share is rows with points above 0
Top and bottom subjectsSubjects with at least five graded learners
Applications decidedCounted once, at the first move to offered, admitted, rejected or enrolled. offered is kept so older history still counts
Applications pendingdraft, submitted or approved. Long-pending is over 30 days old, at most 50
Staff who leftDeactivated, suspended or deleted in the window. There is no employment end date
Teaching loadsubject_x_teacher rows per teacher, in buckets 0, 1-3, 4-6, 7+
Open enquiriesnew or contacted, or resolved after the window end. Median hours use the first contacted entry and resolved_at

Comparisons use the previous month, the previous term on that campus, or for the school document the previous term number across the school. Grades are left out when no campus term covers the window end.

The daily tick

Two cron jobs, cron.schoolReportsMonthly and cron.schoolReportsTermly, both default to 0 0 * * *: 00:00 UTC, which is 03:00 in Kampala. CRON_ENABLED=0 turns them off. Older plan and onboarding notes quote other times; the env schema is what runs.

Monthly tickTermly tick
Which schoolsActive, with the school reports flag onSame
PeriodThe previous month in the school's time zone (default Africa/Kampala)Terms that ended in the last 45 days, grouped by school, year and term number
Existing runLeft alone, even if failedPassed back in, so later campuses and the full term can be added
One school failsLogged, the next school runsLogged, the next group runs

On this page