2020-09-12 17:09:23 +03:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/muety/wakapi/models"
|
|
|
|
"github.com/muety/wakapi/utils"
|
|
|
|
)
|
|
|
|
|
|
|
|
// https://shields.io/endpoint
|
|
|
|
|
|
|
|
const (
|
|
|
|
defaultLabel = "coding time"
|
|
|
|
defaultColor = "#2D3748" // not working
|
|
|
|
)
|
|
|
|
|
|
|
|
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,
|
2021-12-26 19:02:14 +03:00
|
|
|
Message: utils.FmtWakatimeDuration(summary.TotalTime()),
|
2020-09-12 17:09:23 +03:00
|
|
|
Color: defaultColor,
|
|
|
|
}
|
|
|
|
}
|