feat(platform): skip vehicle sections for unresolved lookup
This commit is contained in:
@@ -112,6 +112,9 @@ func TestHandlerVehicleDetailKeepsUnresolvedLookupOutOfVIN(t *testing.T) {
|
|||||||
if body.Data.VIN == "64646848247" {
|
if body.Data.VIN == "64646848247" {
|
||||||
t.Fatalf("unresolved lookup should not be returned as top-level VIN: %s", rec.Body.String())
|
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) {
|
func TestHandlerRealtimeLocations(t *testing.T) {
|
||||||
|
|||||||
@@ -77,6 +77,28 @@ func (s *Service) VehicleDetail(ctx context.Context, vin string, protocol string
|
|||||||
if queryVIN == "" {
|
if queryVIN == "" {
|
||||||
queryVIN = keyword
|
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"}}
|
realtimeQuery := url.Values{"vin": {queryVIN}, "limit": {"20"}}
|
||||||
historyQuery := url.Values{"vin": {queryVIN}, "limit": {"20"}}
|
historyQuery := url.Values{"vin": {queryVIN}, "limit": {"20"}}
|
||||||
|
|||||||
Reference in New Issue
Block a user