api: Begin implementing an API

This commit is contained in:
Tom 2023-04-28 10:25:36 +02:00
parent 1a5e83be10
commit 2fac0390b1
11 changed files with 186 additions and 23 deletions

View file

@ -79,6 +79,13 @@ type BundleStatistics struct {
TotalMainBundles int `json:"totalMainBundles"`
}
func (bs BundleStatistics) TotalCount() (total int) {
for _, bundle := range bs.Bundles {
total += bundle.Count
}
return
}
type LastEdit struct {
Time time.Time
Valid bool
@ -101,10 +108,7 @@ func (bs BundleStatistics) LastEdit() (le LastEdit) {
}
func (bs BundleStatistics) Summary() string {
var totalCount int
for _, bundle := range bs.Bundles {
totalCount += bundle.Count
}
totalCount := bs.TotalCount()
if totalCount == 0 {
return ""
}