Add first-response times to the weekly support report

Node · Node · intermediate · modification

The weekly support report now shows how fast each queue answers. `ticketRepo.listWeekTickets` also selects each ticket's first-response time in whole seconds (null while the ticket has no agent reply). The new `src/reports/responseTimes.js` turns one queue's times into `{ answered, unanswered, medianSeconds, p90Seconds }`, with the mean of the two middle values for an even count and a nearest-rank p90, and `weeklySupportReport.js` adds that summary to every queue row. A queue with nothing answered shows null rather than a misleading 0. Tests for the helper and for the report rows are in `test/reports/responseTimes.test.js` and `test/reports/weeklySupportReport.test.js`.

Helpdesk backend on Node 22 (CommonJS) with Express 4 and PostgreSQL 16 through `pg` 8. Existing and unchanged: `src/db.js` exports the shared `pg` Pool, created with `options: '-c timezone=Europe/Berlin'`, so date arithmetic in SQL (such as the `+ interval '7 days'` week end) runs in Berlin time; `GET /api/reports/support/weekly` (`src/routes/reports.js`) checks `weekStart` (a Monday 00:00 Europe/Berlin, passed on as an ISO 8601 string with its offset), calls `buildWeeklySupportReport` and hands any error to the app's error handler with `next(err)`; the support dashboard reads this JSON, and its new columns ship separately. Tables: `support_queues (id integer primary key, name text not null)`, queues are never deleted; `tickets (id integer primary key, queue_id integer not null references support_queues, created_at timestamptz not null, first_response_at timestamptz null, solved_at timestamptz null)`. `first_response_at` is set once, by the existing reply handler, when the first agent reply is posted, and a CHECK constraint keeps it at or after `created_at`. The product started in 2019, so no time difference comes anywhere near the `integer` range. At most 30 queues and 20,000 tickets are opened in a week in total. The repo has no database-backed tests (`npm test` runs without a database), so SQL changes are checked by hand at review.

Requirements

Files touched

Review this PR

Node practice