dis: Display initial statistics

This commit is contained in:
Tom Wiesing 2022-11-16 16:44:24 +01:00
parent 6d30a42e56
commit 964e74a9f4
No known key found for this signature in database
12 changed files with 252 additions and 7 deletions

View 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
}

View 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();
}