ADR-013 Phase 3 complete: asset-panels + asset-presentation + map-overlays renderers

This commit is contained in:
2026-07-18 23:10:27 -04:00
parent 69922a4e16
commit fd2ab0ab1c
3 changed files with 105 additions and 6 deletions

View File

@@ -363,13 +363,18 @@ def map_overlay():
"""
today = date.today()
query = db.session.query(MeasuringTool).join(Asset).filter(Asset.isactive == True)
# Overlay contract (ADR-010): [{assetid, color, label}] joined by assetid.
# Only decorate tools that are actually due/overdue - a marker with no entry
# gets no badge.
data = []
for tool in query.all():
status = derive_status(tool.nextcalibrationdate, today)
if status not in ('overdue', 'duesoon'):
continue
data.append({
'assetid': tool.assetid,
'calibrationstatus': status,
'statuscolor': STATUS_COLORS.get(status, STATUS_COLORS['unknown']),
'color': STATUS_COLORS.get(status, STATUS_COLORS['unknown']),
'label': 'Overdue' if status == 'overdue' else 'Due soon',
})
return success_response(data)