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 {
|
if len(body.Data.Protocols) < 2 {
|
||||||
t.Fatalf("resolve should include available source protocols, got %+v", body.Data.Protocols)
|
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) {
|
func TestHandlerVehicleResolveKeepsUnresolvedKeyword(t *testing.T) {
|
||||||
|
|||||||
@@ -64,15 +64,16 @@ type VehicleCoverageRow struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type VehicleIdentityResolution struct {
|
type VehicleIdentityResolution struct {
|
||||||
LookupKey string `json:"lookupKey"`
|
LookupKey string `json:"lookupKey"`
|
||||||
Resolved bool `json:"resolved"`
|
Resolved bool `json:"resolved"`
|
||||||
VIN string `json:"vin"`
|
VIN string `json:"vin"`
|
||||||
Plate string `json:"plate"`
|
Plate string `json:"plate"`
|
||||||
Phone string `json:"phone"`
|
Phone string `json:"phone"`
|
||||||
OEM string `json:"oem"`
|
OEM string `json:"oem"`
|
||||||
Protocols []string `json:"protocols"`
|
Protocols []string `json:"protocols"`
|
||||||
Online bool `json:"online"`
|
Online bool `json:"online"`
|
||||||
LastSeen string `json:"lastSeen"`
|
LastSeen string `json:"lastSeen"`
|
||||||
|
ServiceStatus *VehicleServiceStatus `json:"serviceStatus,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type VehicleDetail struct {
|
type VehicleDetail struct {
|
||||||
|
|||||||
@@ -601,6 +601,9 @@ func buildVehicleIdentityResolution(keyword string, vehicles []VehicleRow) Vehic
|
|||||||
if !strings.EqualFold(vehicle.VIN, identity.VIN) {
|
if !strings.EqualFold(vehicle.VIN, identity.VIN) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if result.ServiceStatus == nil && vehicle.ServiceStatus != nil {
|
||||||
|
result.ServiceStatus = vehicle.ServiceStatus
|
||||||
|
}
|
||||||
if vehicle.Online {
|
if vehicle.Online {
|
||||||
result.Online = true
|
result.Online = true
|
||||||
}
|
}
|
||||||
@@ -619,5 +622,26 @@ func buildVehicleIdentityResolution(keyword string, vehicles []VehicleRow) Vehic
|
|||||||
result.Protocols = appendIfMissing(result.Protocols, vehicle.Protocol)
|
result.Protocols = appendIfMissing(result.Protocols, vehicle.Protocol)
|
||||||
}
|
}
|
||||||
sort.Strings(result.Protocols)
|
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
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func boolToInt(value bool) int {
|
||||||
|
if value {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export interface VehicleIdentityResolution {
|
|||||||
protocols: string[];
|
protocols: string[];
|
||||||
online: boolean;
|
online: boolean;
|
||||||
lastSeen: string;
|
lastSeen: string;
|
||||||
|
serviceStatus?: VehicleServiceStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VehicleDetail {
|
export interface VehicleDetail {
|
||||||
|
|||||||
Reference in New Issue
Block a user