add user info to metrics
This commit is contained in:
parent
d6412605f2
commit
2883a66f49
|
@ -77,6 +77,7 @@ class Controller extends BaseController
|
||||||
['labels' => ['state' => 'arrived', 'working' => 'yes'], 'value'
|
['labels' => ['state' => 'arrived', 'working' => 'yes'], 'value'
|
||||||
=> $this->stats->usersState(true)],
|
=> $this->stats->usersState(true)],
|
||||||
],
|
],
|
||||||
|
'users_info' => ['type' => 'gauge', $this->stats->usersInfo()],
|
||||||
'users_force_active' => ['type' => 'gauge', $this->stats->forceActiveUsers()],
|
'users_force_active' => ['type' => 'gauge', $this->stats->forceActiveUsers()],
|
||||||
'users_pronouns' => ['type' => 'gauge', $this->stats->usersPronouns()],
|
'users_pronouns' => ['type' => 'gauge', $this->stats->usersPronouns()],
|
||||||
'licenses' => [
|
'licenses' => [
|
||||||
|
|
|
@ -69,6 +69,14 @@ class Stats
|
||||||
return $query->count('users_state.user_id');
|
return $query->count('users_state.user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function usersInfo(): int
|
||||||
|
{
|
||||||
|
return State::query()
|
||||||
|
->whereNotNull('user_info')
|
||||||
|
->whereNot('user_info', '')
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
public function forceActiveUsers(): int
|
public function forceActiveUsers(): int
|
||||||
{
|
{
|
||||||
return State::whereForceActive(true)->count();
|
return State::whereForceActive(true)->count();
|
||||||
|
|
|
@ -287,6 +287,17 @@ class StatsTest extends TestCase
|
||||||
$this->assertEquals(1, $stats->usersState(false, false));
|
$this->assertEquals(1, $stats->usersState(false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Engelsystem\Controllers\Metrics\Stats::usersInfo
|
||||||
|
*/
|
||||||
|
public function testUsersInfo(): void
|
||||||
|
{
|
||||||
|
$this->addUsers();
|
||||||
|
|
||||||
|
$stats = new Stats($this->database);
|
||||||
|
$this->assertEquals(1, $stats->usersInfo());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Engelsystem\Controllers\Metrics\Stats::forceActiveUsers
|
* @covers \Engelsystem\Controllers\Metrics\Stats::forceActiveUsers
|
||||||
*/
|
*/
|
||||||
|
@ -474,7 +485,7 @@ class StatsTest extends TestCase
|
||||||
$this->addUser(['arrived' => 1], ['pronoun' => 'unicorn'], ['language' => 'lo_RM', 'email_shiftinfo' => true]);
|
$this->addUser(['arrived' => 1], ['pronoun' => 'unicorn'], ['language' => 'lo_RM', 'email_shiftinfo' => true]);
|
||||||
$this->addUser(['arrived' => 1, 'got_voucher' => 2], ['shirt_size' => 'XXL'], ['language' => 'lo_RM']);
|
$this->addUser(['arrived' => 1, 'got_voucher' => 2], ['shirt_size' => 'XXL'], ['language' => 'lo_RM']);
|
||||||
$this->addUser(
|
$this->addUser(
|
||||||
['arrived' => 1, 'got_voucher' => 9, 'force_active' => true],
|
['arrived' => 1, 'got_voucher' => 9, 'force_active' => true, 'user_info' => 'Info'],
|
||||||
[],
|
[],
|
||||||
['theme' => 1],
|
['theme' => 1],
|
||||||
['drive_car' => true, 'drive_12t' => true]
|
['drive_car' => true, 'drive_12t' => true]
|
||||||
|
|
Loading…
Reference in New Issue