Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
NotificationMonitoringService
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 5
30
0.00% covered (danger)
0.00%
0 / 1
 stats
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 queue
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 success
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 failed
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 logs
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Modules\NotificationModule\Services;
4
5use App\Modules\NotificationModule\Models\NotificationQueueModel;
6
7class NotificationMonitoringService
8{
9    public function stats(): array
10    {
11        $model = model(NotificationQueueModel::class);
12
13        return [
14            'pending' => (clone $model)->where('status', 'pending')->countAllResults(),
15            'processing' => (clone $model)->where('status', 'processing')->countAllResults(),
16            'sent' => (clone $model)->where('status', 'sent')->countAllResults(),
17            'failed' => (clone $model)->where('status', 'failed')->countAllResults(),
18        ];
19    }
20
21    public function queue(int $limit = 50)
22    {
23        return model(NotificationQueueModel::class)
24            ->orderBy('id', 'DESC')
25            ->findAll($limit);
26    }
27
28    public function success(int $limit = 50)
29    {
30        return model(NotificationQueueModel::class)
31            ->where('status', 'sent')
32            ->orderBy('id', 'DESC')
33            ->findAll($limit);
34    }
35
36    public function failed(int $limit = 50)
37    {
38        return model(NotificationQueueModel::class)
39            ->where('status', 'failed')
40            ->orderBy('id', 'DESC')
41            ->findAll($limit);
42    }
43
44    public function logs(): array
45    {
46        return [];
47    }
48}