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

Method GetPeakHours

cli/workspace/memory/patterns.go:105–130  ·  view source on GitHub ↗

GetPeakHours returns the top N hours of activity.

(n int)

Source from the content-addressed store, hash-verified

103
104// GetPeakHours returns the top N hours of activity.
105func (pd *PatternDetector) GetPeakHours(n int) []int {
106 pd.mu.RLock()
107 defer pd.mu.RUnlock()
108
109 type hourCount struct {
110 hour int
111 count int
112 }
113 var hours []hourCount
114 for h, c := range pd.stats.HourDistribution {
115 if c > 0 {
116 hours = append(hours, hourCount{h, c})
117 }
118 }
119 sort.Slice(hours, func(i, j int) bool {
120 return hours[i].count > hours[j].count
121 })
122 if n > len(hours) {
123 n = len(hours)
124 }
125 result := make([]int, n)
126 for i := 0; i < n; i++ {
127 result[i] = hours[i].hour
128 }
129 return result
130}
131
132// GetTopCommands returns the N most used commands.
133func (pd *PatternDetector) GetTopCommands(n int) []string {

Callers 1

showMemoryStatsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected