statistics: Better display on the front page

This commit is contained in:
Tom Wiesing 2022-11-16 19:51:17 +01:00
parent bc1bf0db1c
commit 9a1cf4e53b
No known key found for this signature in database
12 changed files with 181 additions and 59 deletions

View file

@ -84,14 +84,31 @@ type BundleStatistics struct {
Count int `json:"entities"`
LastEdit int `json:"lastEdit"`
LastEdit phpx.TimeInt `json:"lastEdit"`
MainBundle phpx.BooleanIsh `json:"mainBundle"`
MainBundle phpx.PHPBoolean `json:"mainBundle"`
} `json:"bundleStatistics"`
TotalBundles int `json:"totalBundles"`
TotalMainBundles int `json:"totalMainBundles"`
}
type LastEdit struct {
Time time.Time
Valid bool
}
// LastEdit returns the last time any bundle was edited, and if any edit was bigger than the reference time
func (bs BundleStatistics) LastEdit() (le LastEdit) {
for _, bundle := range bs.Bundles {
time := bundle.LastEdit.Time()
if time.After(le.Time) {
le.Valid = true
le.Time = time
}
}
return
}
func (bs BundleStatistics) Summary() string {
var totalCount int
for _, bundle := range bs.Bundles {