From 98788aeede671e5aad543f670797a2b0341e4c94 Mon Sep 17 00:00:00 2001 From: Noah Date: Thu, 21 Mar 2024 17:58:42 -0500 Subject: [PATCH] feat(times): Sort time log items by date (fix #10) --- times.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/times.go b/times.go index a21ccfe..0deefe5 100644 --- a/times.go +++ b/times.go @@ -3,6 +3,7 @@ package main import ( "fmt" "os" + "sort" "time" "github.com/charmbracelet/bubbles/table" @@ -56,6 +57,10 @@ func getTimeLogs(since time.Time, on_process_repo func(repo gitea.Repository, to page++ } } + // Sort the times by Created At + sort.Slice(times, func(i, j int) bool { + return times[i].Created.Compare(times[j].Created) > 1 + }) return times } @@ -104,7 +109,7 @@ func times() { } }() - since := time.Now().AddDate(0, 0, -7) + since := time.Now().AddDate(0, -6, 0) times := getTimeLogs(since, func(repo gitea.Repository, took time.Duration) { p.Send(IndicatorInfo{ info: fmt.Sprintf("%s / %s", repo.Owner.UserName, repo.Name),