feat(platform): return service status in vehicle overview

This commit is contained in:
lingniu
2026-07-04 03:00:50 +08:00
parent 8dfbdc83e5
commit 1a86e5d38c
7 changed files with 65 additions and 19 deletions

View File

@@ -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