feat(platform): return service status in vehicle overview
This commit is contained in:
@@ -296,9 +296,33 @@ func buildVehicleServiceOverview(vin string, lookupKey string, resolution *Vehic
|
||||
overview.PrimaryProtocol = overview.Protocols[0]
|
||||
}
|
||||
overview.CoverageStatus = coverageStatus(overview.SourceCount, overview.OnlineSourceCount)
|
||||
resolved := identity != nil && strings.TrimSpace(identity.VIN) != ""
|
||||
if !resolved && resolution != nil {
|
||||
resolved = resolution.Resolved
|
||||
}
|
||||
overview.ServiceStatus = buildVehicleServiceStatus(resolved, statusesForOverview(overview))
|
||||
return overview
|
||||
}
|
||||
|
||||
func statusesForOverview(overview *VehicleServiceOverview) []VehicleSourceStatus {
|
||||
statuses := make([]VehicleSourceStatus, 0, overview.SourceCount)
|
||||
for index, protocol := range overview.Protocols {
|
||||
statuses = append(statuses, VehicleSourceStatus{
|
||||
Protocol: protocol,
|
||||
Online: index < overview.OnlineSourceCount,
|
||||
LastSeen: overview.LastSeen,
|
||||
})
|
||||
}
|
||||
for len(statuses) < overview.SourceCount {
|
||||
statuses = append(statuses, VehicleSourceStatus{
|
||||
Protocol: "UNKNOWN",
|
||||
Online: len(statuses) < overview.OnlineSourceCount,
|
||||
LastSeen: overview.LastSeen,
|
||||
})
|
||||
}
|
||||
return statuses
|
||||
}
|
||||
|
||||
func pageCount(total int, itemCount int) int {
|
||||
if total > 0 {
|
||||
return total
|
||||
|
||||
Reference in New Issue
Block a user