MCPcopy Create free account
hub / github.com/diillson/chatcli / RecordSessionEnd

Method RecordSessionEnd

cli/workspace/memory/patterns.go:84–95  ·  view source on GitHub ↗

RecordSessionEnd updates average session duration.

(duration time.Duration)

Source from the content-addressed store, hash-verified

82
83// RecordSessionEnd updates average session duration.
84func (pd *PatternDetector) RecordSessionEnd(duration time.Duration) {
85 pd.mu.Lock()
86 defer pd.mu.Unlock()
87
88 // Incremental average
89 n := float64(pd.stats.SessionCount)
90 if n <= 0 {
91 n = 1
92 }
93 pd.stats.AvgSessionSecs = pd.stats.AvgSessionSecs + (duration.Seconds()-pd.stats.AvgSessionSecs)/n
94 pd.persist()
95}
96
97// GetStats returns a copy of the current stats.
98func (pd *PatternDetector) GetStats() UsageStats {

Callers 1

cleanupMethod · 0.80

Calls 3

persistMethod · 0.95
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected