dis: Display initial statistics
This commit is contained in:
parent
6d30a42e56
commit
964e74a9f4
12 changed files with 252 additions and 7 deletions
|
|
@ -1,12 +1,15 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# This script is used to start a user shell inside the docker container.
|
||||
# if the user is not www-data, re-invoke self as www-data
|
||||
if [ "$USER" != "www-data" ]; then
|
||||
sudo -u www-data /bin/bash /user_shell.sh "$@"
|
||||
exit $?
|
||||
fi
|
||||
|
||||
# Now start a shell in the proper path
|
||||
cd "/var/www/data/project"
|
||||
export "PATH=/var/www/data/project/vendor/bin:$PATH"
|
||||
|
||||
if [ "$USER" = "www-data" ]; then
|
||||
/bin/bash "$@"
|
||||
else
|
||||
sudo -u www-data /bin/bash "$@"
|
||||
fi;
|
||||
# Re-invoke the actual command
|
||||
/bin/bash "$@"
|
||||
|
|
@ -38,6 +38,9 @@ type Information struct {
|
|||
LastUpdate time.Time
|
||||
LastCron time.Time
|
||||
|
||||
// Statistics of the wisski (TODO: fix me)
|
||||
Statistics Statistics
|
||||
|
||||
// List of backups made
|
||||
Snapshots []models.Export
|
||||
|
||||
|
|
@ -49,3 +52,39 @@ type Information struct {
|
|||
Prefixes []string // list of prefixes
|
||||
Pathbuilders map[string]string // all the pathbuilders
|
||||
}
|
||||
|
||||
type Statistics struct {
|
||||
Activity struct {
|
||||
MostVisited string `json:"mostVisited"`
|
||||
PageVisits []struct {
|
||||
URL string `json:"url"`
|
||||
Visits int `json:"visits"`
|
||||
} `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"`
|
||||
Triplestore struct {
|
||||
Graphs []struct {
|
||||
URI string `json:"uri"`
|
||||
Count int `json:"triples"`
|
||||
} `json:"graphStatistics"`
|
||||
Total int `json:"totalTriples"`
|
||||
} `json:"triplestore"`
|
||||
Users struct {
|
||||
LastLogin string `json:"lastLogin"`
|
||||
TotalUsers int `json:"totalUsers"`
|
||||
} `json:"users"`
|
||||
}
|
||||
|
|
|
|||
37
internal/wisski/ingredient/php/extras/stats.go
Normal file
37
internal/wisski/ingredient/php/extras/stats.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package extras
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"log"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
)
|
||||
|
||||
type Stats struct {
|
||||
ingredient.Base
|
||||
|
||||
PHP *php.PHP
|
||||
}
|
||||
|
||||
//go:embed stats.php
|
||||
var statsPHP string
|
||||
|
||||
// Get fetches all statistics from the server
|
||||
func (stats *Stats) Get(server *phpx.Server) (data ingredient.Statistics, err error) {
|
||||
err = stats.PHP.ExecScript(server, &data, statsPHP, "export_statistics")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (stats *Stats) Fetch(flags ingredient.FetchFlags, info *ingredient.Information) (err error) {
|
||||
if flags.Quick {
|
||||
return
|
||||
}
|
||||
|
||||
info.Statistics, _ = stats.Get(flags.Server)
|
||||
return
|
||||
}
|
||||
8
internal/wisski/ingredient/php/extras/stats.php
Normal file
8
internal/wisski/ingredient/php/extras/stats.php
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
function export_statistics() {
|
||||
$service = 'wisski_statistics.statistics';
|
||||
if (empty(\Drupal::hasService($service))) return (object)[];
|
||||
$statistics = \Drupal::service($service);
|
||||
return $statistics->update();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue