dis: Display initial statistics
This commit is contained in:
parent
6d30a42e56
commit
964e74a9f4
12 changed files with 252 additions and 7 deletions
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