feat: Add call duration to call detail view
This commit is contained in:
@@ -52,11 +52,18 @@ func (s *CallFlowStore) AddPacket(p *Packet) *CallFlow {
|
||||
}
|
||||
|
||||
flow, exists := s.flows[p.CallID]
|
||||
|
||||
// Determine timestamp to use
|
||||
ts := p.Timestamp
|
||||
if ts.IsZero() {
|
||||
ts = time.Now()
|
||||
}
|
||||
|
||||
if !exists {
|
||||
flow = &CallFlow{
|
||||
CallID: p.CallID,
|
||||
Packets: make([]*Packet, 0),
|
||||
StartTime: time.Now(),
|
||||
StartTime: ts,
|
||||
From: p.From,
|
||||
To: p.To,
|
||||
State: CallStateInitial,
|
||||
@@ -65,7 +72,10 @@ func (s *CallFlowStore) AddPacket(p *Packet) *CallFlow {
|
||||
}
|
||||
|
||||
flow.Packets = append(flow.Packets, p)
|
||||
flow.EndTime = time.Now()
|
||||
// Always update EndTime to the latest packet's timestamp
|
||||
if ts.After(flow.EndTime) {
|
||||
flow.EndTime = ts
|
||||
}
|
||||
|
||||
// Update call state based on packet
|
||||
s.updateState(flow, p)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"telephony-inspector/internal/capture"
|
||||
"telephony-inspector/internal/config"
|
||||
@@ -713,6 +714,11 @@ func (m Model) renderCallDetail() string {
|
||||
b.WriteString(fmt.Sprintf("From: %s\n", flow.From))
|
||||
b.WriteString(fmt.Sprintf("To: %s\n", flow.To))
|
||||
b.WriteString(fmt.Sprintf("State: %s\n", flow.State))
|
||||
|
||||
// Calculate and display duration
|
||||
duration := flow.EndTime.Sub(flow.StartTime)
|
||||
b.WriteString(fmt.Sprintf("Duration: %s\n", duration.Round(time.Millisecond)))
|
||||
|
||||
b.WriteString(fmt.Sprintf("Packets: %d\n\n", len(flow.Packets)))
|
||||
|
||||
// Network Summary Section
|
||||
|
||||
Reference in New Issue
Block a user