Jul 30 - Update backend for iPad follow-up request function

This commit is contained in:
Nguyen Ngo
2026-07-30 15:07:23 -04:00
parent 455534ccda
commit 12bcda2994
+26
View File
@@ -13,6 +13,7 @@ PATCH /api/v1/inspections/<inspection_id>
GET /api/v1/inspections
Returns the authenticated inspector's own inspection history.
Supports ?limit=N&offset=N&facility_id=N&status=completed
&follow_up_required=true
"""
import logging
@@ -235,6 +236,13 @@ def list_inspections():
status str filter by status (completed, in_progress, flagged)
from_date str ISO date (YYYY-MM-DD) — include inspections on/after this date
to_date str ISO date (YYYY-MM-DD) — include inspections on/before this date
follow_up_required
str "true"/"1" — only inspections a director has flagged as
needing a follow-up and that no re-inspection has answered
yet (flagged + completed + no child), matching what
"Follow-up" means on the web. Drives the iPad's FOLLOW-UP
REQUESTED card, so it must return the complete outstanding
set, not just the recent page the history list shows.
Response 200
------------
@@ -271,6 +279,24 @@ def list_inspections():
if status:
query = query.filter(Inspection.status == status)
if request.args.get('follow_up_required', '').lower() in ('true', '1'):
# Must mean exactly what "Follow-up" means everywhere on the web
# (inspections.list / reports status_filter == 'follow_up'): flagged,
# completed, and not yet answered by a linked re-inspection.
#
# The ~follow_ups.any() clause is the one that matters. The web execute
# route never clears follow_up_required on the parent — it only stops
# listing it once a child exists — so filtering on the flag alone would
# return follow-ups that were already satisfied on the web, forever.
# On the iPad those rows are undismissable: pull_follow_up_requests()
# keeps receiving them and update(from:) resets fulfilledLocally, so the
# FOLLOW-UP REQUESTED card would never clear. (The mobile POST path does
# clear the parent flag, so only web-completed re-inspections stick.)
query = query.filter(
Inspection.follow_up_required.is_(True),
Inspection.status == 'completed',
).filter(~Inspection.follow_ups.any())
from_date_str = request.args.get('from_date')
if from_date_str:
try: