feat(platform): filter vehicle rows by service status
This commit is contained in:
@@ -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 ` +
|
||||
|
||||
Reference in New Issue
Block a user