Show statistics on the public overview page

This commit is contained in:
Tom Wiesing 2022-11-16 17:00:10 +01:00
parent 964e74a9f4
commit bc1bf0db1c
No known key found for this signature in database
4 changed files with 47 additions and 15 deletions

View file

@ -2,6 +2,10 @@
This file contains signficant news items for the distillery.
# Showing Statistics (2022-11-16)
- The distillery nows shows generic statistics on the public homepage
- detailed statistics can be found on the admin interface
# Refactored SSH Support (2022-11-12)
- Fully refactored ssh for users to use a real OpenSSH Server along with a small custom proxy in between
- It is now possible for developers to directly use e.g. [VSCode Remote SSH](https://code.visualstudio.com/docs/remote/ssh) to develop new WissKI features directly on the distillery.

View file

@ -25,6 +25,9 @@
<h3>{{.Slug}}</h3>
<p>
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer">{{.URL}}</a><br>
<small>
{{ .Statistics.Bundles.Summary }}
</small>
</p>
</div>
{{ end }}

View file

@ -73,7 +73,7 @@ func (home *Home) homeRender() ([]byte, error) {
i := i
wissKI := instance
eg.Go(func() (err error) {
context.Instances[i], err = wissKI.Info().Information(true)
context.Instances[i], err = wissKI.Info().Information(false)
return
})
}

View file

@ -1,6 +1,7 @@
package ingredient
import (
"fmt"
"time"
"github.com/FAU-CDI/wisski-distillery/internal/models"
@ -62,20 +63,7 @@ type Statistics struct {
} `json:"pageVisits"`
TotalEditsLastWeek int `json:"totalEditsLastWeek"`
} `json:"activity"`
Bundles struct {
Bundles []struct {
Label string `json:"label"`
MachineName string `json:"machineName"`
Count int `json:"entities"`
LastEdit int `json:"lastEdit"`
MainBundle phpx.BooleanIsh `json:"mainBundle"`
} `json:"bundleStatistics"`
TotalBundles int `json:"totalBundles"`
TotalMainBundles int `json:"totalMainBundles"`
} `json:"bundles"`
Bundles BundleStatistics `json:"bundles"`
Triplestore struct {
Graphs []struct {
URI string `json:"uri"`
@ -88,3 +76,40 @@ type Statistics struct {
TotalUsers int `json:"totalUsers"`
} `json:"users"`
}
type BundleStatistics struct {
Bundles []struct {
Label string `json:"label"`
MachineName string `json:"machineName"`
Count int `json:"entities"`
LastEdit int `json:"lastEdit"`
MainBundle phpx.BooleanIsh `json:"mainBundle"`
} `json:"bundleStatistics"`
TotalBundles int `json:"totalBundles"`
TotalMainBundles int `json:"totalMainBundles"`
}
func (bs BundleStatistics) Summary() string {
var totalCount int
for _, bundle := range bs.Bundles {
totalCount += bundle.Count
}
if totalCount == 0 {
return ""
}
entitySubject := "Entities"
if totalCount == 1 {
entitySubject = "Entity"
}
bundleSubject := "Bundles"
if len(bs.Bundles) == 1 {
bundleSubject = "Bundle"
}
return fmt.Sprintf("%d %s in %d %s", totalCount, entitySubject, len(bs.Bundles), bundleSubject)
}