1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Oliverde8\PhpEtlBundle\Controller\Admin; |
4
|
|
|
|
5
|
|
|
use Oliverde8\PhpEtlBundle\Entity\EtlExecution; |
6
|
|
|
use Oliverde8\PhpEtlBundle\Repository\EtlExecutionRepository; |
7
|
|
|
use Oliverde8\PhpEtlBundle\Security\EtlExecutionVoter; |
8
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
10
|
|
|
use Symfony\Component\Routing\Annotation\Route; |
11
|
|
|
|
12
|
|
|
class EtlDashboardController extends AbstractController |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
protected EtlExecutionRepository $etlExecutionRepository; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* EtlDashboardController constructor. |
19
|
|
|
* |
20
|
|
|
* @param EtlExecutionRepository $etlExecutionRepository |
21
|
|
|
*/ |
22
|
|
|
public function __construct(EtlExecutionRepository $etlExecutionRepository) |
23
|
|
|
{ |
24
|
|
|
$this->etlExecutionRepository = $etlExecutionRepository; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @Route("/etl/execution/dashboard", name="etl_execution_dashboard") |
30
|
|
|
*/ |
31
|
|
|
public function index($startDate = null, $endDate = null): Response |
32
|
|
|
{ |
33
|
|
|
$this->denyAccessUnlessGranted(EtlExecutionVoter::DASHBOARD, EtlExecution::class); |
34
|
|
|
|
35
|
|
|
if (is_null($endDate)) { |
36
|
|
|
$endDate = new \DateTime(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
if (is_null($startDate)) { |
40
|
|
|
$startDate = new \DateTime('7 days ago'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
//TODO add Acl here for future proofing. |
44
|
|
|
return $this->render( |
45
|
|
|
"@Oliverde8PhpEtl/admin/dashboard.html.twig", |
46
|
|
|
[ |
47
|
|
|
'num_waiting' => $this->etlExecutionRepository->getCountInStatus($startDate, $endDate, EtlExecution::STATUS_WAITING), |
48
|
|
|
'num_running' => $this->etlExecutionRepository->getCountInStatus($startDate, $endDate, EtlExecution::STATUS_RUNNING), |
49
|
|
|
'num_success' => $this->etlExecutionRepository->getCountInStatus($startDate, $endDate, EtlExecution::STATUS_SUCCESS), |
50
|
|
|
'num_failure' => $this->etlExecutionRepository->getCountInStatus($startDate, $endDate, EtlExecution::STATUS_FAILURE), |
51
|
|
|
'max_wait_time' => $this->etlExecutionRepository->getMaxWaitTime($startDate, $endDate), |
52
|
|
|
'avg_wait_time' => $this->etlExecutionRepository->getAvgWaitTime($startDate, $endDate), |
53
|
|
|
'most_executed' => $this->etlExecutionRepository->getMostExecutedJobs($startDate, $endDate, 10), |
54
|
|
|
'most_time_spent' => $this->etlExecutionRepository->getMostTimeSpentJobs($startDate, $endDate, 10), |
55
|
|
|
'longest' => $this->etlExecutionRepository->getLongestJobs($startDate, $endDate, 10), |
56
|
|
|
'crudController' =>EtlExecutionCrudController::class |
57
|
|
|
] |
58
|
|
|
); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|