1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00

fix: support project query param for alltime endpoint

This commit is contained in:
Ferdinand Mütsch
2020-09-11 20:22:33 +02:00
parent 84e9559860
commit a8009e107d
4 changed files with 31 additions and 7 deletions

View File

@@ -44,9 +44,15 @@ func (h *CompatV1AllHandler) ApiGet(w http.ResponseWriter, r *http.Request) {
return
}
total := summary.TotalTime()
vm := &v1.AllTimeVieModel{
Data: &v1.AllTimeVieModelData{
var total time.Duration
if key := values.Get("project"); key != "" {
total = summary.TotalTimeBy(models.SummaryProject, key)
} else {
total = summary.TotalTime()
}
vm := &v1.AllTimeViewModel{
Data: &v1.AllTimeViewModelData{
Seconds: float32(total),
Text: utils.FmtWakatimeDuration(total * time.Second),
IsUpToDate: true,