Change module path from 'cburn' to 'github.com/theirongolddev/cburn' to enable standard Go remote installation: go install github.com/theirongolddev/cburn@latest This is a BREAKING CHANGE for any external code importing this module (though as a CLI tool, this is unlikely to affect anyone). All internal imports updated to use the new module path. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
72 lines
1.4 KiB
Go
72 lines
1.4 KiB
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/theirongolddev/cburn/internal/cli"
|
|
"github.com/theirongolddev/cburn/internal/pipeline"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var hourlyCmd = &cobra.Command{
|
|
Use: "hourly",
|
|
Short: "Activity by hour of day",
|
|
RunE: runHourly,
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(hourlyCmd)
|
|
}
|
|
|
|
func runHourly(_ *cobra.Command, _ []string) error {
|
|
result, err := loadData()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(result.Sessions) == 0 {
|
|
fmt.Println("\n No sessions found.")
|
|
return nil
|
|
}
|
|
|
|
filtered, since, until := applyFilters(result.Sessions)
|
|
hours := pipeline.AggregateHourly(filtered, since, until)
|
|
|
|
fmt.Println()
|
|
fmt.Println(cli.RenderTitle(fmt.Sprintf("ACTIVITY BY HOUR Last %dd (local time)", flagDays)))
|
|
fmt.Println()
|
|
|
|
// Find max for bar scaling
|
|
maxPrompts := 0
|
|
for _, h := range hours {
|
|
if h.Prompts > maxPrompts {
|
|
maxPrompts = h.Prompts
|
|
}
|
|
}
|
|
|
|
maxBarWidth := 40
|
|
for _, h := range hours {
|
|
barLen := 0
|
|
if maxPrompts > 0 {
|
|
barLen = h.Prompts * maxBarWidth / maxPrompts
|
|
}
|
|
bar := strings.Repeat("█", barLen)
|
|
|
|
promptStr := cli.FormatNumber(int64(h.Prompts))
|
|
fmt.Printf(" %02d:00 │ %6s │ %s\n", h.Hour, promptStr, bar)
|
|
}
|
|
|
|
// Find peak hour
|
|
peakHour := 0
|
|
for _, h := range hours {
|
|
if h.Prompts > hours[peakHour].Prompts {
|
|
peakHour = h.Hour
|
|
}
|
|
}
|
|
fmt.Printf("\n Peak: %02d:00 (%s prompts)\n\n",
|
|
peakHour, cli.FormatNumber(int64(hours[peakHour].Prompts)))
|
|
|
|
return nil
|
|
}
|