feat(times): Sort time log items by date (fix #10)

This commit is contained in:
Noah 2024-03-21 17:58:42 -05:00
parent 0a503a8a0c
commit 98788aeede

View File

@ -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),