From 3cb2d3479b0d765608793c9648d46fa55a6613f8 Mon Sep 17 00:00:00 2001 From: lingniu Date: Sat, 4 Jul 2026 00:22:39 +0800 Subject: [PATCH] feat(platform): skip vehicle sections for unresolved lookup --- .../api/internal/platform/handler_test.go | 3 +++ .../apps/api/internal/platform/service.go | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/vehicle-data-platform/apps/api/internal/platform/handler_test.go b/vehicle-data-platform/apps/api/internal/platform/handler_test.go index a2ae7d18..f5831298 100644 --- a/vehicle-data-platform/apps/api/internal/platform/handler_test.go +++ b/vehicle-data-platform/apps/api/internal/platform/handler_test.go @@ -112,6 +112,9 @@ func TestHandlerVehicleDetailKeepsUnresolvedLookupOutOfVIN(t *testing.T) { if body.Data.VIN == "64646848247" { t.Fatalf("unresolved lookup should not be returned as top-level VIN: %s", rec.Body.String()) } + if len(body.Data.Sources) != 0 || len(body.Data.SourceStatus) != 0 || len(body.Data.Raw.Items) != 0 || len(body.Data.History.Items) != 0 || len(body.Data.Mileage.Items) != 0 { + t.Fatalf("unresolved lookup should not return vehicle data sections: %+v", body.Data) + } } func TestHandlerRealtimeLocations(t *testing.T) { diff --git a/vehicle-data-platform/apps/api/internal/platform/service.go b/vehicle-data-platform/apps/api/internal/platform/service.go index f556f66b..d876e773 100644 --- a/vehicle-data-platform/apps/api/internal/platform/service.go +++ b/vehicle-data-platform/apps/api/internal/platform/service.go @@ -77,6 +77,28 @@ func (s *Service) VehicleDetail(ctx context.Context, vin string, protocol string if queryVIN == "" { queryVIN = keyword } + if resolvedVIN == "" { + qualityQuery := url.Values{"keyword": {keyword}, "limit": {"20"}} + if protocol != "" { + qualityQuery.Set("protocol", protocol) + } + quality, err := s.store.QualityIssues(ctx, qualityQuery) + if err != nil { + return VehicleDetail{}, err + } + return VehicleDetail{ + VIN: "", + LookupKey: keyword, + LookupResolved: false, + Sources: []string{}, + SourceStatus: []VehicleSourceStatus{}, + Realtime: []RealtimeLocationRow{}, + History: Page[HistoryLocationRow]{Items: []HistoryLocationRow{}, Limit: 20, Offset: 0}, + Raw: Page[RawFrameRow]{Items: []RawFrameRow{}, Limit: 10, Offset: 0}, + Mileage: Page[DailyMileageRow]{Items: []DailyMileageRow{}, Limit: 20, Offset: 0}, + Quality: quality, + }, nil + } realtimeQuery := url.Values{"vin": {queryVIN}, "limit": {"20"}} historyQuery := url.Values{"vin": {queryVIN}, "limit": {"20"}}