fix: Implement proper scrolling and sorting for Analysis calls list

This commit is contained in:
Jose Luis Montañes Ojados
2026-01-19 23:07:25 +01:00
parent d234bfb427
commit a5ba4d6c11
2 changed files with 95 additions and 7 deletions

View File

@@ -153,6 +153,27 @@ func (s *CallFlowStore) GetRecentFlows(n int) []*CallFlow {
return flows
}
// GetSortedFlows returns all call flows sorted by StartTime (oldest first)
func (s *CallFlowStore) GetSortedFlows() []*CallFlow {
flows := s.GetAllFlows()
// Sort by start time ascending (oldest first), then by CallID for stable order
for i := 0; i < len(flows)-1; i++ {
for j := i + 1; j < len(flows); j++ {
// Compare by StartTime first
if flows[i].StartTime.After(flows[j].StartTime) {
flows[i], flows[j] = flows[j], flows[i]
} else if flows[i].StartTime.Equal(flows[j].StartTime) {
// If same time, sort by CallID for stable order
if flows[i].CallID > flows[j].CallID {
flows[i], flows[j] = flows[j], flows[i]
}
}
}
}
return flows
}
// Count returns the number of call flows
func (s *CallFlowStore) Count() int {
s.mu.RLock()