Jul 21 - Update QR code destination page, shows recent inspection cleaning quality

This commit is contained in:
2026-07-21 12:00:27 -04:00
parent fc366fbf8d
commit 507d9b5c64
4 changed files with 47 additions and 24 deletions
+34 -11
View File
@@ -110,12 +110,34 @@ def _rating_label(score):
return ('Needs attention', 'danger')
def _recent_rows(inspections):
"""Shape recent completed inspections for the occupant page.
Each row carries the date and the occupant-friendly quality label/colour.
The raw score percentage is deliberately NOT included in the payload — the
occupant sees the quality label only, so the number cannot leak into the
rendered page. Also excludes inspector names, template/checklist names,
and any per-item detail (occupant-safe).
"""
rows = []
for i in inspections:
score = float(i.overall_score) if i.overall_score is not None else None
label, colour = _rating_label(score) # None -> 'Not yet rated'
rows.append({
'date': i.inspection_date,
'label': label,
'colour': colour,
})
return rows
def _build_summary(facility: Facility) -> dict:
"""Assemble the occupant-facing summary for a facility.
Occupant-safe (rule 74): aggregate rating, counts, a score trend, and
recent inspection DATES only — no checklist/template names, no
per-inspection scores, no issue descriptions, and no severity/SLA detail.
recent inspections showing date + quality LABEL only (no score
percentage) — no checklist/template names, no inspector names, no issue
descriptions, and no per-item or severity/SLA detail.
"""
fid = facility.id
now = now_eastern()
@@ -172,7 +194,8 @@ def _build_summary(facility: Facility) -> dict:
else:
trend_delta = None
# Recent inspection DATES only (no checklist names, no scores)
# Recent inspections: date + score + quality label (no checklist/template
# names, no inspector names, no per-item detail).
recent = (
Inspection.query
.filter(Inspection.facility_id == fid,
@@ -181,7 +204,7 @@ def _build_summary(facility: Facility) -> dict:
.limit(5)
.all()
)
recent_dates = [i.inspection_date for i in recent]
recent_inspections = _recent_rows(recent)
# Open-issue COUNT (linked directly or via an area) — no details exposed
open_issue_count = (
@@ -213,9 +236,9 @@ def _build_summary(facility: Facility) -> dict:
'inspections_90': inspections_90,
'open_issue_count': open_issue_count,
'resolved_90': resolved_90,
'trend_delta': trend_delta,
'last_inspected': last_insp.inspection_date if last_insp else None,
'recent_dates': recent_dates,
'trend_delta': trend_delta,
'last_inspected': last_insp.inspection_date if last_insp else None,
'recent_inspections': recent_inspections,
}
@@ -297,7 +320,7 @@ def _build_area_summary(area, facility) -> dict:
.limit(5)
.all()
)
recent_dates = [i.inspection_date for i in recent]
recent_inspections = _recent_rows(recent)
open_issue_count = (
Issue.query
@@ -326,9 +349,9 @@ def _build_area_summary(area, facility) -> dict:
'inspections_90': inspections_90,
'open_issue_count': open_issue_count,
'resolved_90': resolved_90,
'trend_delta': trend_delta,
'last_inspected': last_insp.inspection_date if last_insp else None,
'recent_dates': recent_dates,
'trend_delta': trend_delta,
'last_inspected': last_insp.inspection_date if last_insp else None,
'recent_inspections': recent_inspections,
}
+6 -6
View File
@@ -102,14 +102,14 @@
<span class="badge bg-{{ rating_colour }} fs-6">{{ rating_label }}</span>
</div>
{# ── Recent inspections (DATES ONLY — occupant-safe) ── #}
{% if recent_dates %}
{# ── Recent inspections (date + quality label, no % — occupant-safe) ── #}
{% if recent_inspections %}
<div class="card-soft p-3 mb-3">
<div class="sec-title mb-2"><i class="bi bi-clipboard-check me-1"></i> Recent Inspections</div>
{% for d in recent_dates %}
<div class="list-line py-2 d-flex align-items-center justify-content-between">
<span>{{ d.strftime('%b %d, %Y') }}</span>
<span class="text-success small"><i class="bi bi-check-circle-fill"></i> Completed</span>
{% for r in recent_inspections %}
<div class="list-line py-2 d-flex align-items-center justify-content-between gap-2">
<span>{{ r.date.strftime('%b %d, %Y') }}</span>
<span class="badge bg-{{ r.colour }}">{{ r.label }}</span>
</div>
{% endfor %}
<div class="text-muted small mt-2">This area is inspected regularly by our quality team.</div>
+5 -5
View File
@@ -103,13 +103,13 @@
</div>
{# ── Recent inspections (DATES ONLY — occupant-safe) ── #}
{% if recent_dates %}
{% if recent_inspections %}
<div class="card-soft p-3 mb-3">
<div class="sec-title mb-2"><i class="bi bi-clipboard-check me-1"></i> Recent Inspections</div>
{% for d in recent_dates %}
<div class="list-line py-2 d-flex align-items-center justify-content-between">
<span>{{ d.strftime('%b %d, %Y') }}</span>
<span class="text-success small"><i class="bi bi-check-circle-fill"></i> Completed</span>
{% for r in recent_inspections %}
<div class="list-line py-2 d-flex align-items-center justify-content-between gap-2">
<span>{{ r.date.strftime('%b %d, %Y') }}</span>
<span class="badge bg-{{ r.colour }}">{{ r.label }}</span>
</div>
{% endfor %}
<div class="text-muted small mt-2">This facility is inspected regularly by our quality team.</div>