fix(monitor): hold conflicting terminal coordinates
This commit is contained in:
@@ -402,8 +402,8 @@ func buildVehicleRealtimeSQL(query url.Values) SQLQuery {
|
||||
// Ordering only by updated_at makes the selected point flap whenever protocols
|
||||
// report at different cadences. When every source is stale, recency remains the
|
||||
// safest fallback so an old high-priority source cannot mask newer evidence.
|
||||
orderExpr := `CASE WHEN l.updated_at >= DATE_SUB(NOW(), INTERVAL 2 MINUTE) THEN 0 ELSE 1 END ASC, ` +
|
||||
`CASE WHEN l.updated_at >= DATE_SUB(NOW(), INTERVAL 2 MINUTE) THEN CASE l.protocol ` +
|
||||
orderExpr := `CASE WHEN l.updated_at >= DATE_SUB(NOW(), INTERVAL 10 MINUTE) THEN 0 ELSE 1 END ASC, ` +
|
||||
`CASE WHEN l.updated_at >= DATE_SUB(NOW(), INTERVAL 10 MINUTE) THEN CASE l.protocol ` +
|
||||
`WHEN 'GB32960' THEN 10 WHEN 'YUTONG_MQTT' THEN 20 WHEN 'JT808' THEN 30 ELSE 100 END ELSE 100 END ASC, ` +
|
||||
`l.updated_at DESC, l.protocol ASC`
|
||||
return SQLQuery{
|
||||
|
||||
@@ -209,7 +209,7 @@ func TestBuildVehicleRealtimeSQL(t *testing.T) {
|
||||
t.Fatalf("SQL should keep vehicle-level stable pagination order: %s", built.Text)
|
||||
}
|
||||
for _, want := range []string{
|
||||
"INTERVAL 2 MINUTE",
|
||||
"INTERVAL 10 MINUTE",
|
||||
"WHEN 'GB32960' THEN 10",
|
||||
"WHEN 'YUTONG_MQTT' THEN 20",
|
||||
"WHEN 'JT808' THEN 30",
|
||||
|
||||
Reference in New Issue
Block a user