Mar 05 2026: implement reinspect label debug
This commit is contained in:
@@ -465,12 +465,6 @@ def view(inspection_id):
|
|||||||
issues = inspection.issues.order_by(Issue.reported_at.desc()).all()
|
issues = inspection.issues.order_by(Issue.reported_at.desc()).all()
|
||||||
|
|
||||||
# ── Score comparison against parent inspection ────────────────────────
|
# ── Score comparison against parent inspection ────────────────────────
|
||||||
# Scores live in form_data (field_id -> value) inside inspection.notes.
|
|
||||||
# We walk the shared form_fields schema and compare current vs. parent
|
|
||||||
# responses per scoreable field, resolving item names via three strategies:
|
|
||||||
# 1. Leftmost text field value on the same grid row (e.g. "Brick Floor")
|
|
||||||
# 2. field['label'] if explicitly set
|
|
||||||
# 3. Nearest preceding section/label element text
|
|
||||||
comparison = None
|
comparison = None
|
||||||
if inspection.parent and inspection.parent.status == 'completed':
|
if inspection.parent and inspection.parent.status == 'completed':
|
||||||
parent = inspection.parent
|
parent = inspection.parent
|
||||||
@@ -484,6 +478,25 @@ def view(inspection_id):
|
|||||||
except (json.JSONDecodeError, TypeError):
|
except (json.JSONDecodeError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# ── DEBUG: log raw schema + form_data so we can see what's actually stored ──
|
||||||
|
current_app.logger.warning(
|
||||||
|
'COMPARISON DEBUG | inspection_id=%s | current_form_data=%s',
|
||||||
|
inspection_id, json.dumps(form_data)
|
||||||
|
)
|
||||||
|
current_app.logger.warning(
|
||||||
|
'COMPARISON DEBUG | parent_id=%s | parent_form_data=%s',
|
||||||
|
parent.id, json.dumps(parent_form_data)
|
||||||
|
)
|
||||||
|
current_app.logger.warning(
|
||||||
|
'COMPARISON DEBUG | form_fields=%s',
|
||||||
|
json.dumps([
|
||||||
|
{'id': f.get('id'), 'type': f.get('type'), 'row': f.get('row'),
|
||||||
|
'col': f.get('col'), 'label': f.get('label'), 'text_content': f.get('text_content')}
|
||||||
|
for f in form_fields
|
||||||
|
])
|
||||||
|
)
|
||||||
|
# ── END DEBUG ──
|
||||||
|
|
||||||
scoreable_types = ('rating', 'checkbox', 'radio')
|
scoreable_types = ('rating', 'checkbox', 'radio')
|
||||||
|
|
||||||
# Collect all text/textarea fields per row, keyed by (col, fid)
|
# Collect all text/textarea fields per row, keyed by (col, fid)
|
||||||
|
|||||||
Reference in New Issue
Block a user