wisski-cloud-distillery/internal/wisski/ingredient/php/extras/stats.go
Tom Wiesing 890022ae64
internal: Annotate all components with groups
This commit ensures that the compiler has to check every component
against the groups they implement by explicitly annotating the
appropriate interfaces.
2022-11-30 11:08:46 +01:00

39 lines
883 B
Go

package extras
import (
"context"
_ "embed"
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
"github.com/FAU-CDI/wisski-distillery/internal/status"
"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
}
var (
_ ingredient.WissKIFetcher = (*Stats)(nil)
)
//go:embed stats.php
var statsPHP string
// Get fetches all statistics from the server
func (stats *Stats) Get(ctx context.Context, server *phpx.Server) (data status.Statistics, err error) {
err = stats.PHP.ExecScript(ctx, server, &data, statsPHP, "export_statistics")
return
}
func (stats *Stats) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
if flags.Quick {
return
}
info.Statistics, _ = stats.Get(flags.Context, flags.Server)
return
}