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

feat: comprehensive summary-level filtering (resolve #262)

This commit is contained in:
Ferdinand Mütsch
2021-12-26 17:02:14 +01:00
parent 8a3e6f0179
commit a279548c89
25 changed files with 333 additions and 183 deletions

View File

@ -3,7 +3,6 @@ package v1
import (
"github.com/muety/wakapi/models"
"github.com/muety/wakapi/utils"
"time"
)
// https://shields.io/endpoint
@ -20,18 +19,11 @@ type BadgeData struct {
Color string `json:"color"`
}
func NewBadgeDataFrom(summary *models.Summary, filters *models.Filters) *BadgeData {
var total time.Duration
if hasFilter, _, _ := filters.One(); hasFilter {
total = summary.TotalTimeByFilters(filters)
} else {
total = summary.TotalTime()
}
func NewBadgeDataFrom(summary *models.Summary) *BadgeData {
return &BadgeData{
SchemaVersion: 1,
Label: defaultLabel,
Message: utils.FmtWakatimeDuration(total),
Message: utils.FmtWakatimeDuration(summary.TotalTime()),
Color: defaultColor,
}
}