Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| GetAnalyticsDashboardQuery | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace ImovelZapAi\Analytics\Application\Queries; |
| 6 | |
| 7 | use App\Models\User; |
| 8 | use ImovelZapAi\Analytics\Application\Actions\GetOrCreateDashboardLayoutAction; |
| 9 | use ImovelZapAi\Analytics\Domain\Enums\DashboardRole; |
| 10 | |
| 11 | final class GetAnalyticsDashboardQuery |
| 12 | { |
| 13 | public function __construct( |
| 14 | private readonly GetExecutiveKpisQuery $kpis, |
| 15 | private readonly GetFunnelQuery $funnel, |
| 16 | private readonly GetRankingQuery $ranking, |
| 17 | private readonly ListAnalyticsAlertsQuery $alerts, |
| 18 | private readonly GetOrCreateDashboardLayoutAction $layoutAction, |
| 19 | ) {} |
| 20 | |
| 21 | /** |
| 22 | * @param array{from?: string, to?: string, days?: int} $filters |
| 23 | * @return array<string, mixed> |
| 24 | */ |
| 25 | public function execute(string $tenantId, User $user, DashboardRole $role, array $filters = []): array |
| 26 | { |
| 27 | return [ |
| 28 | 'role' => $role->value, |
| 29 | 'kpis' => $this->kpis->execute($tenantId, $filters), |
| 30 | 'funnel' => $this->funnel->execute($tenantId, $filters), |
| 31 | 'rankings' => $this->ranking->execute($tenantId, $filters), |
| 32 | 'alerts' => $this->alerts->execute($tenantId, ['status' => 'open', 'limit' => 10]), |
| 33 | 'layout' => $this->layoutAction->execute($tenantId, $user, $role), |
| 34 | ]; |
| 35 | } |
| 36 | } |