add shifttypes and angeltypes count to metrics
This commit is contained in:
parent
7d5837c5f1
commit
1798ccda83
|
@ -139,6 +139,8 @@ class Controller extends BaseController
|
||||||
'locales' => ['type' => 'gauge', 'help' => 'The locales users have configured'] + $userLocales,
|
'locales' => ['type' => 'gauge', 'help' => 'The locales users have configured'] + $userLocales,
|
||||||
'themes' => ['type' => 'gauge', 'help' => 'The themes users have configured'] + $userThemes,
|
'themes' => ['type' => 'gauge', 'help' => 'The themes users have configured'] + $userThemes,
|
||||||
'locations' => ['type' => 'gauge', $this->stats->locations()],
|
'locations' => ['type' => 'gauge', $this->stats->locations()],
|
||||||
|
'angeltypes' => ['type' => 'gauge', $this->stats->angeltypes()],
|
||||||
|
'shifttypes' => ['type' => 'gauge', $this->stats->shifttypes()],
|
||||||
'shifts' => ['type' => 'gauge', $this->stats->shifts()],
|
'shifts' => ['type' => 'gauge', $this->stats->shifts()],
|
||||||
'announcements' => [
|
'announcements' => [
|
||||||
'type' => 'gauge',
|
'type' => 'gauge',
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Engelsystem\Controllers\Metrics;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Engelsystem\Database\Database;
|
use Engelsystem\Database\Database;
|
||||||
|
use Engelsystem\Models\AngelType;
|
||||||
use Engelsystem\Models\EventConfig;
|
use Engelsystem\Models\EventConfig;
|
||||||
use Engelsystem\Models\Faq;
|
use Engelsystem\Models\Faq;
|
||||||
use Engelsystem\Models\LogEntry;
|
use Engelsystem\Models\LogEntry;
|
||||||
|
@ -16,6 +17,7 @@ use Engelsystem\Models\OAuth;
|
||||||
use Engelsystem\Models\Question;
|
use Engelsystem\Models\Question;
|
||||||
use Engelsystem\Models\Location;
|
use Engelsystem\Models\Location;
|
||||||
use Engelsystem\Models\Shifts\Shift;
|
use Engelsystem\Models\Shifts\Shift;
|
||||||
|
use Engelsystem\Models\Shifts\ShiftType;
|
||||||
use Engelsystem\Models\User\License;
|
use Engelsystem\Models\User\License;
|
||||||
use Engelsystem\Models\User\PasswordReset;
|
use Engelsystem\Models\User\PasswordReset;
|
||||||
use Engelsystem\Models\User\PersonalData;
|
use Engelsystem\Models\User\PersonalData;
|
||||||
|
@ -297,6 +299,18 @@ class Stats
|
||||||
->count();
|
->count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shifttypes(): int
|
||||||
|
{
|
||||||
|
return ShiftType::query()
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function angeltypes(): int
|
||||||
|
{
|
||||||
|
return AngelType::query()
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
public function shifts(): int
|
public function shifts(): int
|
||||||
{
|
{
|
||||||
return Shift::count();
|
return Shift::count();
|
||||||
|
|
|
@ -6,6 +6,7 @@ namespace Engelsystem\Test\Unit\Controllers\Metrics;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Engelsystem\Controllers\Metrics\Stats;
|
use Engelsystem\Controllers\Metrics\Stats;
|
||||||
|
use Engelsystem\Models\AngelType;
|
||||||
use Engelsystem\Models\Faq;
|
use Engelsystem\Models\Faq;
|
||||||
use Engelsystem\Models\LogEntry;
|
use Engelsystem\Models\LogEntry;
|
||||||
use Engelsystem\Models\Message;
|
use Engelsystem\Models\Message;
|
||||||
|
@ -16,6 +17,7 @@ use Engelsystem\Models\Question;
|
||||||
use Engelsystem\Models\Location;
|
use Engelsystem\Models\Location;
|
||||||
use Engelsystem\Models\Shifts\Shift;
|
use Engelsystem\Models\Shifts\Shift;
|
||||||
use Engelsystem\Models\Shifts\ShiftEntry;
|
use Engelsystem\Models\Shifts\ShiftEntry;
|
||||||
|
use Engelsystem\Models\Shifts\ShiftType;
|
||||||
use Engelsystem\Models\User\License;
|
use Engelsystem\Models\User\License;
|
||||||
use Engelsystem\Models\User\PasswordReset;
|
use Engelsystem\Models\User\PasswordReset;
|
||||||
use Engelsystem\Models\User\PersonalData;
|
use Engelsystem\Models\User\PersonalData;
|
||||||
|
@ -200,6 +202,34 @@ class StatsTest extends TestCase
|
||||||
$this->assertEquals(4, $stats->locations());
|
$this->assertEquals(4, $stats->locations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Engelsystem\Controllers\Metrics\Stats::angeltypes
|
||||||
|
*/
|
||||||
|
public function testAngeltypes(): void
|
||||||
|
{
|
||||||
|
(new AngelType(['name' => 'AngelType 1']))->save();
|
||||||
|
(new AngelType(['name' => 'Second AngelType']))->save();
|
||||||
|
(new AngelType(['name' => 'Another AngelType']))->save();
|
||||||
|
(new AngelType(['name' => 'Old AngelType']))->save();
|
||||||
|
|
||||||
|
$stats = new Stats($this->database);
|
||||||
|
$this->assertEquals(4, $stats->angeltypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Engelsystem\Controllers\Metrics\Stats::shifttypes
|
||||||
|
*/
|
||||||
|
public function testShifttypes(): void
|
||||||
|
{
|
||||||
|
(new ShiftType(['name' => 'ShiftType 1', 'description' => 'rtfm']))->save();
|
||||||
|
(new ShiftType(['name' => 'Second ShiftType', 'description' => 'pebkac']))->save();
|
||||||
|
(new ShiftType(['name' => 'Another ShiftType', 'description' => 'id10t error']))->save();
|
||||||
|
(new ShiftType(['name' => 'Old ShiftType', 'description' => 'layer 8']))->save();
|
||||||
|
|
||||||
|
$stats = new Stats($this->database);
|
||||||
|
$this->assertEquals(4, $stats->shifttypes());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Engelsystem\Controllers\Metrics\Stats::shifts
|
* @covers \Engelsystem\Controllers\Metrics\Stats::shifts
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue