feat(monitor): aggregate nationwide fleet by province
This commit is contained in:
@@ -541,6 +541,33 @@ func TestMonitorMapUsesMeaningfulClustersAndReleasesPointsAtDetailZoom(t *testin
|
||||
}
|
||||
}
|
||||
|
||||
func TestMonitorMapNationwideReturnsScopedProvinceSeedsAndGridFallback(t *testing.T) {
|
||||
vehicles := Page[VehicleRealtimeRow]{Items: []VehicleRealtimeRow{
|
||||
{VIN: "GUANGDONG-1", Online: true, LocationAvailable: true, Longitude: 113.260, Latitude: 23.130},
|
||||
{VIN: "GUANGDONG-2", Online: false, LocationAvailable: true, Longitude: 113.265, Latitude: 23.135, LastSeen: "2026-07-15T08:00:00+08:00"},
|
||||
{VIN: "OUTSIDE-STATUS", Online: true, LocationAvailable: true, Longitude: 121.47, Latitude: 31.23, SpeedKmh: 20},
|
||||
{VIN: "NO-LOCATION", Online: true},
|
||||
}, Total: 4, Limit: 4}
|
||||
|
||||
result, err := buildMonitorMapResponse(vehicles, url.Values{
|
||||
"zoom": {"5"},
|
||||
"status": {"offline"},
|
||||
"bounds": {"113,22,114,24"},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if result.Mode != "provinces" || result.Total != 1 || len(result.ProvincePoints) != 1 {
|
||||
t.Fatalf("nationwide response must expose only filtered, located province seeds: %+v", result)
|
||||
}
|
||||
if result.ProvincePoints[0].Status != "offline" || result.ProvincePoints[0].Longitude != 113.265 {
|
||||
t.Fatalf("unexpected province seed: %+v", result.ProvincePoints[0])
|
||||
}
|
||||
if len(result.Points)+len(result.Clusters) == 0 {
|
||||
t.Fatal("nationwide response must retain a grid fallback when AMap district data is unavailable")
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMonitorMapTenThousandVehicles(b *testing.B) {
|
||||
vehicles := syntheticMonitorVehicles(10_000)
|
||||
query := url.Values{"zoom": {"5"}}
|
||||
|
||||
Reference in New Issue
Block a user