1
0
mirror of https://github.com/muety/wakapi.git synced 2023-08-10 21:12:56 +03:00
wakapi/models/compat/shields/v1/badge.go
Ferdinand Mütsch 40067d252e fix: non-ascii project badges (resolve #357)
chore: locally generated badges (resolve #348)
2022-04-18 11:39:26 +02:00

30 lines
605 B
Go

package v1
import (
"github.com/muety/wakapi/models"
"github.com/muety/wakapi/utils"
)
// https://shields.io/endpoint
const (
defaultLabel = "wakapi.dev"
defaultColor = "2F855A"
)
type BadgeData struct {
SchemaVersion int `json:"schemaVersion"`
Label string `json:"label"`
Message string `json:"message"`
Color string `json:"color"`
}
func NewBadgeDataFrom(summary *models.Summary) *BadgeData {
return &BadgeData{
SchemaVersion: 1,
Label: defaultLabel,
Message: utils.FmtWakatimeDuration(summary.TotalTime()),
Color: defaultColor,
}
}