feat(times): Sort time log items by date (fix #10)
This commit is contained in:
parent
0a503a8a0c
commit
98788aeede
7
times.go
7
times.go
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/table"
|
"github.com/charmbracelet/bubbles/table"
|
||||||
@ -56,6 +57,10 @@ func getTimeLogs(since time.Time, on_process_repo func(repo gitea.Repository, to
|
|||||||
page++
|
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
|
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) {
|
times := getTimeLogs(since, func(repo gitea.Repository, took time.Duration) {
|
||||||
p.Send(IndicatorInfo{
|
p.Send(IndicatorInfo{
|
||||||
info: fmt.Sprintf("%s / %s", repo.Owner.UserName, repo.Name),
|
info: fmt.Sprintf("%s / %s", repo.Owner.UserName, repo.Name),
|
||||||
|
Loading…
Reference in New Issue
Block a user