feat: Quickstart, Benutzerverwaltung und Orion-Ergebnisbox
This commit is contained in:
parent
4f669a3426
commit
e9e46f2cb4
404 changed files with 1032 additions and 600 deletions
|
|
@ -90,6 +90,26 @@ def default_report_checklists(session: Session = Depends(get_session)) -> list[d
|
|||
@router.get("/dashboard")
|
||||
def dashboard(session: Session = Depends(get_session)) -> dict[str, int]:
|
||||
today = func.current_date()
|
||||
result_groups = {
|
||||
"validation_result_open": ["OFFEN", "offen", None, ""],
|
||||
"validation_result_passed": ["BESTANDEN", "bestanden"],
|
||||
"validation_result_conditional": ["BESTANDEN_MIT_AUFLAGEN", "bestanden_mit_auflagen", "mit_auflagen", "bestanden mit Auflagen"],
|
||||
"validation_result_failed": ["NICHT_BESTANDEN", "nicht_bestanden", "nicht bestanden"],
|
||||
}
|
||||
result_counts = {
|
||||
key: session.scalar(select(func.count()).select_from(Validation).where(Validation.result.in_(values)))
|
||||
or 0
|
||||
for key, values in result_groups.items()
|
||||
if None not in values
|
||||
}
|
||||
result_counts["validation_result_open"] = (
|
||||
session.scalar(
|
||||
select(func.count())
|
||||
.select_from(Validation)
|
||||
.where((Validation.result.in_(["OFFEN", "offen", ""])) | (Validation.result.is_(None)))
|
||||
)
|
||||
or 0
|
||||
)
|
||||
return {
|
||||
"customers": session.scalar(select(func.count()).select_from(Customer)) or 0,
|
||||
"locations": session.scalar(select(func.count()).select_from(Location)) or 0,
|
||||
|
|
@ -137,6 +157,7 @@ def dashboard(session: Session = Depends(get_session)) -> dict[str, int]:
|
|||
.where(Validation.next_validation_on < today)
|
||||
)
|
||||
or 0,
|
||||
**result_counts,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue