feat(platform): include service status in vehicle resolution
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ export interface VehicleIdentityResolution {
|
||||
protocols: string[];
|
||||
online: boolean;
|
||||
lastSeen: string;
|
||||
serviceStatus?: VehicleServiceStatus;
|
||||
}
|
||||
|
||||
export interface VehicleDetail {
|
||||
|
||||
Reference in New Issue
Block a user