2020-09-12 17:09:23 +03:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
2022-12-01 12:57:07 +03:00
|
|
|
"github.com/muety/wakapi/helpers"
|
2020-09-12 17:09:23 +03:00
|
|
|
"github.com/muety/wakapi/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
// https://shields.io/endpoint
|
|
|
|
|
|
|
|
const (
|
2022-04-18 12:39:26 +03:00
|
|
|
defaultLabel = "wakapi.dev"
|
|
|
|
defaultColor = "2F855A"
|
2020-09-12 17:09:23 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type BadgeData struct {
|
|
|
|
SchemaVersion int `json:"schemaVersion"`
|
|
|
|
Label string `json:"label"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Color string `json:"color"`
|
|
|
|
}
|
|
|
|
|
2021-12-26 19:02:14 +03:00
|
|
|
func NewBadgeDataFrom(summary *models.Summary) *BadgeData {
|
2020-09-12 17:09:23 +03:00
|
|
|
return &BadgeData{
|
|
|
|
SchemaVersion: 1,
|
|
|
|
Label: defaultLabel,
|
2022-12-01 12:57:07 +03:00
|
|
|
Message: helpers.FmtWakatimeDuration(summary.TotalTime()),
|
2020-09-12 17:09:23 +03:00
|
|
|
Color: defaultColor,
|
|
|
|
}
|
|
|
|
}
|