DailyReportController

struct DailyReportController : APIRouteCollection

The collection of /api/v3/admin/dailyreport/* route endpoints and handler functions for the daily report to JoCo Cruise Operations.

The server drafts a report from what it can measure, then TwitarrTeam members edit the text and mark it final. See DailyReport.

Handlers

  • listHandler(_:) Asynchronous

    GET /api/v3/admin/dailyreport

    Lists daily reports, newest reporting period first. TwitarrTeam and above.

    URL Query Parameters:

    • ?start=INT, ?limit=INT - pagination, limit 1-200, default 50.

    Declaration

    Swift

    func listHandler(_ req: Request) async throws -> Paginated<DailyReportListData>
  • createHandler(_:) Asynchronous

    POST /api/v3/admin/dailyreport/create

    Measures the reporting window, drafts the report’s text from the numbers, and saves it as a draft. The free-form sections (uptime, escalations, help desk, anything needing JoCo action, fun stats, process notes) start empty.

    Declaration

    Swift

    func createHandler(_ req: Request) async throws -> Response

    Parameters

    requestBody

    DailyReportCreateData. May be empty ({}) to take the default window.

    Return Value

    201 Created with DailyReportData.

  • reportHandler(_:) Asynchronous

    GET /api/v3/admin/dailyreport/:daily_report_id

    Declaration

    Swift

    func reportHandler(_ req: Request) async throws -> DailyReportData

    Return Value

    DailyReportData

  • updateHandler(_:) Asynchronous

    POST /api/v3/admin/dailyreport/:daily_report_id/update

    Changes the fields present in the body. A final report can’t be changed unless the same request sets status back to draft.

    Throws

    409 if the report is final and the request doesn’t reopen it. 400 for an invalid window or an over-long section.

    Declaration

    Swift

    func updateHandler(_ req: Request) async throws -> DailyReportData

    Parameters

    requestBody

    Return Value

    DailyReportData

  • regenerateHandler(_:) Asynchronous

    POST /api/v3/admin/dailyreport/:daily_report_id/regenerate

    Re-measures the report’s (possibly edited) window and redrafts the auto-filled sections: accounts, content, features, moderation, registration codes and flags, and Community Support. Anything a person typed in those sections is replaced; the free-form sections are untouched.

    Throws

    409 if the report is final.

    Declaration

    Swift

    func regenerateHandler(_ req: Request) async throws -> DailyReportData

    Return Value

    DailyReportData

  • htmlHandler(_:) Asynchronous

    GET /api/v3/admin/dailyreport/:daily_report_id/html

    The report as a standalone HTML document, with its own styles, that prints cleanly (print to PDF from the browser). Suitable for emailing.

    URL Query Parameters:

    • ?download=true - send as an attachment instead of displaying inline.

    Declaration

    Swift

    func htmlHandler(_ req: Request) async throws -> Response

    Return Value

    text/html

  • deleteHandler(_:) Asynchronous

    POST /api/v3/admin/dailyreport/:daily_report_id/delete DELETE /api/v3/admin/dailyreport/:daily_report_id

    Deletes a report. It’s soft-deleted: it disappears from the list but stays in the database.

    Declaration

    Swift

    func deleteHandler(_ req: Request) async throws -> HTTPStatus

    Return Value

    204 No Content

Helpers

  • The title trimmed, or nil if there isn’t one (nil or blank).

    Declaration

    Swift

    private static func validatedTitle(_ title: String?) throws -> String?
  • Fills in the default window and checks it’s sensible.

    Declaration

    Swift

    private func resolveWindow(start: Date?, end: Date?, on db: Database) async throws -> (start: Date, end: Date)