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 8cde2362..203eaf7e 100644 --- a/vehicle-data-platform/apps/api/internal/platform/handler_test.go +++ b/vehicle-data-platform/apps/api/internal/platform/handler_test.go @@ -257,6 +257,9 @@ func TestHandlerVehicleResolveReturnsCanonicalIdentity(t *testing.T) { if len(body.Data.Protocols) < 2 { t.Fatalf("resolve should include available source protocols, got %+v", body.Data.Protocols) } + if body.Data.ServiceStatus == nil || body.Data.ServiceStatus.Status != "degraded" { + t.Fatalf("resolve should include canonical service status, got %+v body=%s", body.Data.ServiceStatus, rec.Body.String()) + } } func TestHandlerVehicleResolveKeepsUnresolvedKeyword(t *testing.T) { diff --git a/vehicle-data-platform/apps/api/internal/platform/model.go b/vehicle-data-platform/apps/api/internal/platform/model.go index e222be78..1a48988a 100644 --- a/vehicle-data-platform/apps/api/internal/platform/model.go +++ b/vehicle-data-platform/apps/api/internal/platform/model.go @@ -64,15 +64,16 @@ type VehicleCoverageRow struct { } type VehicleIdentityResolution struct { - LookupKey string `json:"lookupKey"` - Resolved bool `json:"resolved"` - VIN string `json:"vin"` - Plate string `json:"plate"` - Phone string `json:"phone"` - OEM string `json:"oem"` - Protocols []string `json:"protocols"` - Online bool `json:"online"` - LastSeen string `json:"lastSeen"` + LookupKey string `json:"lookupKey"` + Resolved bool `json:"resolved"` + VIN string `json:"vin"` + Plate string `json:"plate"` + Phone string `json:"phone"` + OEM string `json:"oem"` + Protocols []string `json:"protocols"` + Online bool `json:"online"` + LastSeen string `json:"lastSeen"` + ServiceStatus *VehicleServiceStatus `json:"serviceStatus,omitempty"` } type VehicleDetail struct { diff --git a/vehicle-data-platform/apps/api/internal/platform/service.go b/vehicle-data-platform/apps/api/internal/platform/service.go index 55be38a6..474288a6 100644 --- a/vehicle-data-platform/apps/api/internal/platform/service.go +++ b/vehicle-data-platform/apps/api/internal/platform/service.go @@ -601,6 +601,9 @@ func buildVehicleIdentityResolution(keyword string, vehicles []VehicleRow) Vehic if !strings.EqualFold(vehicle.VIN, identity.VIN) { continue } + if result.ServiceStatus == nil && vehicle.ServiceStatus != nil { + result.ServiceStatus = vehicle.ServiceStatus + } if vehicle.Online { result.Online = true } @@ -619,5 +622,26 @@ func buildVehicleIdentityResolution(keyword string, vehicles []VehicleRow) Vehic result.Protocols = appendIfMissing(result.Protocols, vehicle.Protocol) } sort.Strings(result.Protocols) + if result.ServiceStatus == nil { + result.ServiceStatus = buildVehicleCoverageServiceStatus(VehicleCoverageRow{ + VIN: result.VIN, + Plate: result.Plate, + Phone: result.Phone, + OEM: result.OEM, + Protocols: result.Protocols, + SourceCount: len(result.Protocols), + OnlineSourceCount: boolToInt(result.Online), + Online: result.Online, + LastSeen: result.LastSeen, + BindingStatus: "bound", + }) + } return result } + +func boolToInt(value bool) int { + if value { + return 1 + } + return 0 +} diff --git a/vehicle-data-platform/apps/web/src/api/types.ts b/vehicle-data-platform/apps/web/src/api/types.ts index 14d245ab..aaad15d8 100644 --- a/vehicle-data-platform/apps/web/src/api/types.ts +++ b/vehicle-data-platform/apps/web/src/api/types.ts @@ -70,6 +70,7 @@ export interface VehicleIdentityResolution { protocols: string[]; online: boolean; lastSeen: string; + serviceStatus?: VehicleServiceStatus; } export interface VehicleDetail {