Mar 04 2026: Implement some operational features: scheduled reports, issue resolution verification, etc - Phase 6

This commit is contained in:
2026-03-04 17:14:06 -05:00
parent 160f9fec5d
commit 7c0ed93795
22 changed files with 1787 additions and 19 deletions
+14
View File
@@ -94,6 +94,19 @@ def index():
recent_q = recent_q.filter(False)
recent_inspections = recent_q.limit(5).all()
# ── Pending follow-up inspections ────────────────────────────────────
followup_q = Inspection.query.filter_by(
follow_up_required=True, status='completed'
).filter(Inspection.follow_ups == None) # noqa: E711 — SQLAlchemy usage
if is_inspector:
followup_q = followup_q.filter(Inspection.inspector_id == current_user.id)
elif is_customer:
if customer_facility_ids:
followup_q = followup_q.filter(Inspection.facility_id.in_(customer_facility_ids))
else:
followup_q = followup_q.filter(False)
pending_followups = followup_q.count()
# ── System stats (admin/supervisor) ───────────────────────────────────
total_facilities = Facility.query.filter_by(active=True).count() if is_privileged else 0
total_templates = InspectionTemplate.query.count() if is_privileged else 0
@@ -183,4 +196,5 @@ def index():
trend_data = trend_data,
facility_perf = facility_perf,
customer_facilities = customer_facilities,
pending_followups = pending_followups,
)