Helpers
Health metrics
Helpers for querying device health metrics and summary stats
Health metrics helpers
get_health_metrics
- Options:
lookbackSeconds,maxCount; optionaltimestampAnchor(ISO; window end, default now),source,metricName. - Window:
timestamp >= anchor - lookbackSecondsandtimestamp < anchor. Results ordered by timestamp desc, limited bymaxCount. - Returns:
{ status, msg, data: HealthMetric[] }.
get_health_metrics_summary
- Options:
device_id, optionallookbackMinutes(default 60). - Returns:
{ status, msg, data }with one row per metric:metric_name,min_value,max_value,avg_value,count.
Import either helper from /client with a Supabase client as the first argument,
or from /server with only the listed query arguments.