feat(platform): filter vehicle rows by service status

This commit is contained in:
lingniu
2026-07-04 02:26:39 +08:00
parent cbd02956ff
commit e7de41894b
4 changed files with 50 additions and 3 deletions

View File

@@ -27,6 +27,16 @@ func buildVehicleListSQL(query url.Values) SQLQuery {
where = append(where, "s.protocol = ?")
args = append(args, protocol)
}
switch strings.TrimSpace(query.Get("serviceStatus")) {
case "identity_required":
where = append(where, "(b.vin IS NULL OR b.vin = '')")
case "offline":
where = append(where, "b.vin IS NOT NULL", "b.vin <> ''", "COALESCE(vs.source_count, 0) > 0", "COALESCE(vs.online_source_count, 0) = 0")
case "degraded":
where = append(where, "b.vin IS NOT NULL", "b.vin <> ''", "vs.source_count > 0", "vs.online_source_count > 0", "vs.online_source_count < vs.source_count")
case "healthy":
where = append(where, "b.vin IS NOT NULL", "b.vin <> ''", "vs.source_count > 0", "vs.online_source_count = vs.source_count")
}
countArgs := append([]any(nil), args...)
args = append(args, limit, offset)
fromSQL := `FROM vehicle_realtime_snapshot s ` +