Show statistics on the public overview page
This commit is contained in:
parent
964e74a9f4
commit
bc1bf0db1c
4 changed files with 47 additions and 15 deletions
4
NEWS.md
4
NEWS.md
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
This file contains signficant news items for the distillery.
|
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)
|
# 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
|
- 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.
|
- 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.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@
|
||||||
<h3>{{.Slug}}</h3>
|
<h3>{{.Slug}}</h3>
|
||||||
<p>
|
<p>
|
||||||
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer">{{.URL}}</a><br>
|
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer">{{.URL}}</a><br>
|
||||||
|
<small>
|
||||||
|
{{ .Statistics.Bundles.Summary }}
|
||||||
|
</small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func (home *Home) homeRender() ([]byte, error) {
|
||||||
i := i
|
i := i
|
||||||
wissKI := instance
|
wissKI := instance
|
||||||
eg.Go(func() (err error) {
|
eg.Go(func() (err error) {
|
||||||
context.Instances[i], err = wissKI.Info().Information(true)
|
context.Instances[i], err = wissKI.Info().Information(false)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package ingredient
|
package ingredient
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||||
|
|
@ -62,20 +63,7 @@ type Statistics struct {
|
||||||
} `json:"pageVisits"`
|
} `json:"pageVisits"`
|
||||||
TotalEditsLastWeek int `json:"totalEditsLastWeek"`
|
TotalEditsLastWeek int `json:"totalEditsLastWeek"`
|
||||||
} `json:"activity"`
|
} `json:"activity"`
|
||||||
Bundles struct {
|
Bundles BundleStatistics `json:"bundles"`
|
||||||
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"`
|
|
||||||
Triplestore struct {
|
Triplestore struct {
|
||||||
Graphs []struct {
|
Graphs []struct {
|
||||||
URI string `json:"uri"`
|
URI string `json:"uri"`
|
||||||
|
|
@ -88,3 +76,40 @@ type Statistics struct {
|
||||||
TotalUsers int `json:"totalUsers"`
|
TotalUsers int `json:"totalUsers"`
|
||||||
} `json:"users"`
|
} `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)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue