From b3f059ad04fc0f54282aea98c5c2af8d7e46867a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Fri, 21 Dec 2018 20:09:15 +0100 Subject: metrics: Added vouchers and tshirts --- src/Controllers/Metrics/Controller.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/Controllers/Metrics/Controller.php') diff --git a/src/Controllers/Metrics/Controller.php b/src/Controllers/Metrics/Controller.php index 0fd26396..86c21562 100644 --- a/src/Controllers/Metrics/Controller.php +++ b/src/Controllers/Metrics/Controller.php @@ -55,6 +55,17 @@ class Controller extends BaseController $now = microtime(true); $this->checkAuth(); + $tshirtSizes = []; + $userSizes = $this->stats->tshirtSizes(); + + foreach ($this->config->get('tshirt_sizes') as $name => $description) { + $size = $userSizes->where('shirt_size', '=', $name)->sum('count'); + $tshirtSizes[] = [ + 'labels' => ['size' => $name], + $size, + ]; + } + $data = [ $this->config->get('app_name') . ' stats', 'users' => [ @@ -84,6 +95,9 @@ class Controller extends BaseController ['labels' => ['state' => 'freeloaded'], 'value' => $this->stats->workSeconds(null, true)], ], 'worklog_seconds' => ['type' => 'gauge', $this->stats->worklogSeconds()], + 'vouchers' => ['type' => 'counter', $this->stats->vouchers()], + 'tshirts_issued' => ['type' => 'counter', 'help' => 'Issued T-Shirts', $this->stats->tshirts()], + 'tshirt_sizes' => ['type' => 'gauge', 'help' => 'The sizes users have configured'] + $tshirtSizes, 'shifts' => ['type' => 'gauge', $this->stats->shifts()], 'announcements' => [ 'type' => 'gauge', @@ -92,8 +106,8 @@ class Controller extends BaseController ], 'questions' => [ 'type' => 'gauge', - ['labels' => ['answered' => true], 'value' => $this->stats->questions(true)], - ['labels' => ['answered' => false], 'value' => $this->stats->questions(false)], + ['labels' => ['state' => 'answered'], 'value' => $this->stats->questions(true)], + ['labels' => ['state' => 'pending'], 'value' => $this->stats->questions(false)], ], 'messages' => ['type' => 'gauge', $this->stats->messages()], 'password_resets' => ['type' => 'gauge', $this->stats->passwordResets()], -- cgit v1.2.3-54-g00ecf