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.
-
Longest any one text section may be, in characters.
Declaration
Swift
private static let maxSectionLength: Int -
Declaration
Swift
private static let maxTitleLength: Int -
Required. Registers routes to the incoming router.
Declaration
Swift
func registerRoutes(_ app: Application) throws
-
listHandler(_:Asynchronous) GET /api/v3/admin/dailyreportLists 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>Return Value
-
createHandler(_:Asynchronous) POST /api/v3/admin/dailyreport/createMeasures 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 -> ResponseParameters
requestBodyDailyReportCreateData. May be empty ({}) to take the default window.Return Value
201 Created with
DailyReportData. -
reportHandler(_:Asynchronous) GET /api/v3/admin/dailyreport/:daily_report_idDeclaration
Swift
func reportHandler(_ req: Request) async throws -> DailyReportDataReturn Value
-
updateHandler(_:Asynchronous) POST /api/v3/admin/dailyreport/:daily_report_id/updateChanges the fields present in the body. A final report can’t be changed unless the same request sets
statusback todraft.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 -> DailyReportDataParameters
requestBodyReturn Value
-
regenerateHandler(_:Asynchronous) POST /api/v3/admin/dailyreport/:daily_report_id/regenerateRe-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 -> DailyReportDataReturn Value
-
htmlHandler(_:Asynchronous) GET /api/v3/admin/dailyreport/:daily_report_id/htmlThe 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 -> ResponseReturn Value
text/html -
deleteHandler(_:Asynchronous) POST /api/v3/admin/dailyreport/:daily_report_id/deleteDELETE /api/v3/admin/dailyreport/:daily_report_idDeletes a report. It’s soft-deleted: it disappears from the list but stays in the database.
Declaration
Swift
func deleteHandler(_ req: Request) async throws -> HTTPStatusReturn Value
204 No Content
-
The title trimmed, or nil if there isn’t one (nil or blank).
Declaration
Swift
private static func validatedTitle(_ title: String?) throws -> String? -
resolveWindow(start:Asynchronousend: on: ) 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)
View on GitHub