Coverage for apps/core_los/report_builder_schemas.py: 100%
45 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-04 14:06 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-04 14:06 +0000
1"""Django Ninja schemas for the Report Builder endpoints."""
3from __future__ import annotations
5from typing import Any
7from ninja import ModelSchema, Schema
9from apps.core_los.models import CustomReport
12class ReportFieldOut(Schema):
13 key: str
14 label: str
15 type: str
16 filterable: bool
17 groupable: bool
20class MetricOut(Schema):
21 key: str
22 label: str
23 type: str
26class ReportFieldCatalogOut(Schema):
27 fields: list[ReportFieldOut]
28 metrics: list[MetricOut]
31class ReportFilterIn(Schema):
32 field: str
33 op: str
34 value: str | int | float
37class ReportSortIn(Schema):
38 field: str
39 dir: str
42class ReportDefInputSchema(Schema):
43 name: str
44 columns: list[str] = []
45 filters: list[ReportFilterIn] = []
46 group_by: str | None = None
47 metrics: list[str] = []
48 sort: ReportSortIn | None = None
51class ReportDefOut(ModelSchema):
52 class Meta:
53 model = CustomReport
54 fields = [
55 "id", "name", "columns", "filters", "group_by",
56 "metrics", "sort", "system", "created_at",
57 ]
60class ReportColumnOut(Schema):
61 key: str
62 label: str
63 type: str
66class ReportResultOut(Schema):
67 mode: str
68 columns: list[ReportColumnOut]
69 rows: list[dict[str, Any]]
70 totals: dict[str, Any] | None = None
71 row_count: int