@@ -108,16 +108,16 @@ func (m *Model) Update(msg tea.Msg) tea.Cmd {
108108
109109// stateKey builds a string key for change detection.
110110func (m * Model ) stateKey (s domain.AccountSummary , services []domain.ServiceStatus ) string {
111- key := fmt .Sprintf ("%v:%d:%d:%d:%d:%d:%d:%d:%d:%s:%s:%s:%.0f:%.0f :%d" ,
111+ key := fmt .Sprintf ("%v:%d:%d:%d:%d:%d:%d:%d:%d:%s:%s:%s:%v:%v :%d" ,
112112 s .ReadyForUse , s .ServiceCount , s .ActiveServices ,
113113 s .EventCount , s .AnalyzedCount , s .OkServices ,
114114 s .ErrorServices , s .StaleServices , s .QuarantinedCount ,
115115 s .Health , s .Error , s .Warning ,
116- ptrVal ( s .TotalServiceVolumePerHour ) , s .TotalVolumePerHour ,
116+ s .TotalServiceVolumePerHour , s .TotalVolumePerHour ,
117117 len (services ))
118118
119119 for _ , svc := range services {
120- key += fmt .Sprintf ("|%s:%s:%s:%d:%d:%.0f:%.0f:%.2f " ,
120+ key += fmt .Sprintf ("|%s:%s:%s:%d:%d:%v:%v:%v " ,
121121 svc .Name , svc .Health , svc .Warning , svc .LogEventCount , svc .LogEventAnalyzedCount ,
122122 svc .ServiceVolumePerHour , svc .LogEventVolumePerHour , svc .ServiceCostPerHourVolumeUSD )
123123 }
@@ -199,8 +199,8 @@ func (m *Model) renderSummary() string {
199199 }
200200
201201 // Total volume.
202- if s .TotalVolumePerHour > 0 {
203- parts = append (parts , format .Volume (s .TotalVolumePerHour )+ " evt/hr" )
202+ if s .TotalVolumePerHour != nil && * s . TotalVolumePerHour > 0 {
203+ parts = append (parts , format .Volume (* s .TotalVolumePerHour )+ " evt/hr" )
204204 }
205205
206206 // Total cost from account summary (pre-aggregated by control plane).
@@ -238,11 +238,19 @@ func (m *Model) renderServiceTable(width, maxRows int) string {
238238
239239 bar := m .discoveryBar ()
240240 for _ , svc := range visible {
241+ vol := "—"
242+ if svc .ServiceVolumePerHour != nil {
243+ vol = format .Volume (* svc .ServiceVolumePerHour ) + "/hr"
244+ }
245+ cost := "—"
246+ if svc .ServiceCostPerHourVolumeUSD != nil {
247+ cost = format .YearlyCost (* svc .ServiceCostPerHourVolumeUSD )
248+ }
241249 tbl .Row (
242250 m .renderServiceName (svc ),
243251 m .renderLogEvents (svc , bar ),
244- format . Volume ( svc . ServiceVolumePerHour ) + "/hr" ,
245- format . YearlyCost ( svc . ServiceCostPerHourVolumeUSD ) ,
252+ vol ,
253+ cost ,
246254 )
247255 }
248256
@@ -294,7 +302,7 @@ func (m *Model) discoveryBar() progress.Model {
294302// never exactly 100% due to throughput fluctuations).
295303func (m * Model ) renderLogEvents (svc domain.ServiceStatus , bar progress.Model ) string {
296304 count := fmt .Sprintf ("%-5d" , svc .LogEventCount )
297- if svc .ServiceVolumePerHour <= 0 {
305+ if svc .ServiceVolumePerHour == nil || * svc . ServiceVolumePerHour <= 0 {
298306 return count
299307 }
300308 pct := discoveryPercent (svc )
@@ -310,7 +318,10 @@ func summaryDiscoveryPercent(s domain.AccountSummary) int {
310318 if s .TotalServiceVolumePerHour == nil || * s .TotalServiceVolumePerHour <= 0 {
311319 return 100
312320 }
313- pct := int (math .Round (s .TotalVolumePerHour / * s .TotalServiceVolumePerHour * 100 ))
321+ if s .TotalVolumePerHour == nil {
322+ return 0
323+ }
324+ pct := int (math .Round (* s .TotalVolumePerHour / * s .TotalServiceVolumePerHour * 100 ))
314325 if pct > 100 {
315326 pct = 100
316327 }
@@ -319,19 +330,15 @@ func summaryDiscoveryPercent(s domain.AccountSummary) int {
319330
320331// discoveryPercent computes how much of a service's volume has been classified.
321332func discoveryPercent (svc domain.ServiceStatus ) int {
322- if svc .ServiceVolumePerHour <= 0 {
333+ if svc .ServiceVolumePerHour == nil || * svc . ServiceVolumePerHour <= 0 {
323334 return 100
324335 }
325- pct := int (math .Round (svc .LogEventVolumePerHour / svc .ServiceVolumePerHour * 100 ))
336+ if svc .LogEventVolumePerHour == nil {
337+ return 0
338+ }
339+ pct := int (math .Round (* svc .LogEventVolumePerHour / * svc .ServiceVolumePerHour * 100 ))
326340 if pct > 100 {
327341 pct = 100
328342 }
329343 return pct
330344}
331-
332- func ptrVal (p * float64 ) float64 {
333- if p == nil {
334- return 0
335- }
336- return * p
337- }
0 commit comments