ModulesDay Reports

Day Reports

Day Reports is a read-only, derived view on /admin/diaries that aggregates diaries by date and shift. One Day Report = one shift on one day for the current project, rolling up every supervisor’s diary for that shift into a single consolidated record.

A Day Report has no lifecycle of its own — it is not draft, submitted, or confirmed. It reflects a status rollup of its member diaries (for example “2 confirmed · 1 submitted”) and updates automatically as those diaries change. There is nothing to submit or approve on a Day Report.

How it works

/admin/diaries has an in-page grouping toggle at the top of the page:

  • Daily diaries — the individual-diary list, unchanged.
  • Day reports — the new aggregated list, grouped by (date, shift).

Each Day Reports row is one date + shift combination for the current project, showing the supervisors who filed a diary that shift and at-a-glance counts — diaries, activities, labour, plant, issues, and photos — plus the status rollup across the member diaries. Rows only exist for date/shift combinations that have at least one diary; empty configured shifts do not appear.

Clicking a row opens the Day Report detail.

On Daily diaries, tick diaries to change their date, shift, location and more in one go — see Bulk Edit & Undo.

Day Report detail

The detail page is a full-width consolidated report that reads top to bottom as one shift record:

  • KPI summary + weather — diaries, supervisors, activities, labour, plant, and issue counts for the shift, alongside a weather card.
  • Diaries in this shift — the source diaries that make up the report, each linking back to its own diary (supervisor, status, submitted/confirmed time, display id).
  • Activities & quantities — activities rolled up across all diaries in the shift, summed by cost code and unit, with each supervisor’s own activity-description narrative kept intact.
  • Shift records & custom fields — the built-in shift-info fields and every custom field, kept per supervisor rather than flattened into one merged view. Every field type is supported — text, textarea, number, checkbox, dropdown, radio, multiselect, date, time, year, day of week, user, file, address, CSV lookup, and table.
  • Shift handover notes — per-supervisor blocks.
  • Issues raised — issues logged against the shift’s diaries.
  • Photos & files — photos captured across the shift, tagged with their source supervisor.

Every value in the detail links back to its source diary, so office staff can drill from a rolled-up number straight to the individual record it came from.

AI Day Summary

The Day Report detail includes an AI-generated narrative summary that consolidates all supervisors’ diaries for that date and shift into a single readable report. The summary combines:

  • Day-level overview — a brief narrative synthesizing the shift’s activities, labour, and plant usage across all supervisors.
  • Per-supervisor sections — individual summaries covering each supervisor’s activities, issues logged, weather observations, and handover notes.
  • Labour & plant totals — aggregated counts of labour hours and plant usage across the shift.

The summary is generated asynchronously as a background job and updates in real time on the detail page — the card displays status (generating → complete) and refreshes automatically. Regenerating replaces the previous summary entirely.

Who can run it: Only users with the diaries.generate_summary permission (admins and engineers by default). The “Generate summary” button is hidden from other users and when no OpenAI API key is configured in the environment.

Scope: Covers a single date + shift; it is not a scheduled or emailed digest. The AI output is read-only and cannot be edited directly.

Scope & permissions

Day Reports are always scoped to the currently-selected project — there is no cross-project aggregation. They respect the same diary visibility rules as the daily list: a supervisor-scoped user sees a Day Report composed only of their own diaries, and the counts and rollups reflect that scoped set.

v1 limitations

  • Read-only. Day Reports have no create, edit, submit, or approval actions — they are entirely derived from existing diaries.
  • No new persistence. There are no new database tables and no migrations; every Day Report is computed on read from diaries and related tables.
  • No dedicated aggregated PDF export. The detail is print-friendly via the browser; a branded, Temporal-generated aggregated PDF is future work.
  • Web only. There is no mobile Day Reports screen yet.
  • No cross-project or date-range “period report” rollups in this version.

Architecture

  • Fully derived, no migrations. Day Reports compute their grouping from the existing diary uniqueness constraint UNIQUE(project_id, supervisor_id, diary_date, shift_type) — dropping supervisor_id from that key yields the Day Report grain (project_id, diary_date, shift_type).
  • Aggregation queries live in backend/db/queries/day_reports.sql. Every query hard-filters on project_id + org_id + deleted_at IS NULL and applies the same diary RBAC scope block used by ListDiaries, so a Day Report never surfaces a diary the caller couldn’t otherwise see.
  • Go handlers live in backend/api/internal/dayreport/ — a package parallel to diary/, reusing its scope helper. Handlers are read-only: no permission-key mutation checks, just the standard extractOrgContext → scope → service call path.
  • Custom-field answers are assembled in Go by pairing the existing custom_field_definitions (entity_type = 'prestart_diary') with each diary’s custom_field_values, kept per supervisor rather than merged.
  • Real-time — diaries already emit Postgres LISTEN/NOTIFY → WebSocket → TanStack Query invalidation; Day Report queries invalidate on the same diary events, so the list and detail update live with no client polling.
  • Tenant isolation — every list and detail query is scoped by org_id/project_id from the verified session context.

Spec & plan

  • Spec: docs/superpowers/specs/2026-07-01-day-reports-design.md
  • Plan: docs/superpowers/plans/2026-07-01-day-reports.md

See also: Daily Diaries Report for every diary in a date range as a spreadsheet.

See also: Printing & PDF Export to print one diary or save it as a PDF.