diff --git a/NEWS.md b/NEWS.md
index 9a1ad17..a0b0ad6 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -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.
diff --git a/internal/dis/component/control/home/home.html b/internal/dis/component/control/home/home.html
index 0e5d6e4..f03cfca 100644
--- a/internal/dis/component/control/home/home.html
+++ b/internal/dis/component/control/home/home.html
@@ -25,6 +25,9 @@
{{.Slug}}
{{.URL}}
+
+ {{ .Statistics.Bundles.Summary }}
+
{{ end }}
diff --git a/internal/dis/component/control/home/public.go b/internal/dis/component/control/home/public.go
index 175400f..79cef52 100644
--- a/internal/dis/component/control/home/public.go
+++ b/internal/dis/component/control/home/public.go
@@ -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
})
}
diff --git a/internal/wisski/ingredient/fetcher.go b/internal/wisski/ingredient/fetcher.go
index d371fa1..0063f49 100644
--- a/internal/wisski/ingredient/fetcher.go
+++ b/internal/wisski/ingredient/fetcher.go
@@ -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)
+}