1 | <?php |
||
2 | |||
3 | namespace Oliverde8\PhpEtlBundle\Repository; |
||
4 | |||
5 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
||
0 ignored issues
–
show
|
|||
6 | use Doctrine\Persistence\ManagerRegistry; |
||
0 ignored issues
–
show
The type
Doctrine\Persistence\ManagerRegistry was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||
7 | use Oliverde8\PhpEtlBundle\Entity\EtlExecution; |
||
8 | |||
9 | /** |
||
10 | * @method EtlExecution|null find($id, $lockMode = null, $lockVersion = null) |
||
11 | * @method EtlExecution|null findOneBy(array $criteria, array $orderBy = null) |
||
12 | * @method EtlExecution[] findAll() |
||
13 | * @method EtlExecution[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
||
14 | */ |
||
15 | class EtlExecutionRepository extends ServiceEntityRepository |
||
16 | { |
||
17 | public function __construct(ManagerRegistry $registry) |
||
18 | { |
||
19 | parent::__construct($registry, EtlExecution::class); |
||
20 | } |
||
21 | |||
22 | public function save(EtlExecution $execution) |
||
23 | { |
||
24 | $this->_em->persist($execution); |
||
25 | $this->_em->flush(); |
||
26 | } |
||
27 | |||
28 | public function getCountInStatus(\DateTime $startTime, \DateTime $endTime, string $status): int |
||
29 | { |
||
30 | $result = $this->createQueryBuilder('cm') |
||
31 | ->select('COUNT(cm.id) as count') |
||
32 | ->where("cm.createTime > :startTime")->setParameter('startTime', $startTime) |
||
33 | ->andWhere("cm.createTime <= :endTime")->setParameter('endTime', $endTime) |
||
34 | ->andWhere("cm.status = :status")->setParameter('status', $status) |
||
35 | ->getQuery() |
||
36 | ->getSingleResult(); |
||
37 | |||
38 | return (isset($result['count'])) ? $result['count'] : 0; |
||
39 | } |
||
40 | |||
41 | public function getMostExecutedJobs(\DateTime $startTime, \DateTime $endTime, int $maxResults): array |
||
42 | { |
||
43 | return $this->createQueryBuilder('cm') |
||
44 | ->select('cm.name as name, COUNT(cm.id) as count') |
||
45 | ->where("cm.createTime > :startTime")->setParameter('startTime', $startTime) |
||
46 | ->andWhere("cm.createTime <= :endTime")->setParameter('endTime', $endTime) |
||
47 | ->groupBy("cm.name") |
||
48 | ->orderBy("count", 'DESC') |
||
49 | ->setMaxResults($maxResults) |
||
50 | ->getQuery() |
||
51 | ->getArrayResult(); |
||
52 | } |
||
53 | |||
54 | public function getMostTimeSpentJobs(\DateTime $startTime, \DateTime $endTime, int $maxResults): array |
||
55 | { |
||
56 | return $this->createQueryBuilder('cm') |
||
57 | ->select('cm.name as name, SUM(cm.runTime) as runTime') |
||
58 | ->where("cm.createTime > :startTime")->setParameter('startTime', $startTime) |
||
59 | ->andWhere("cm.createTime <= :endTime")->setParameter('endTime', $endTime) |
||
60 | ->groupBy("cm.name") |
||
61 | ->orderBy("runTime", 'DESC') |
||
62 | ->setMaxResults($maxResults) |
||
63 | ->getQuery() |
||
64 | ->getArrayResult(); |
||
65 | } |
||
66 | |||
67 | public function getLongestJobs(\DateTime $startTime, \DateTime $endTime, int $maxResults): array |
||
68 | { |
||
69 | return $this->createQueryBuilder('cm') |
||
70 | ->select('cm.name as name, MAX(cm.runTime) as runTime') |
||
71 | ->where("cm.createTime > :startTime")->setParameter('startTime', $startTime) |
||
72 | ->andWhere("cm.createTime <= :endTime")->setParameter('endTime', $endTime) |
||
73 | ->groupBy("cm.name") |
||
74 | ->orderBy("runTime", 'DESC') |
||
75 | ->setMaxResults($maxResults) |
||
76 | ->getQuery() |
||
77 | ->getArrayResult(); |
||
78 | } |
||
79 | |||
80 | public function getMaxWaitTime(\DateTime $startTime, \DateTime $endTime): int |
||
81 | { |
||
82 | $result = $this->createQueryBuilder('cm') |
||
83 | ->select('MAX(cm.runTime) as waitTime') |
||
84 | ->where("cm.createTime > :startTime")->setParameter('startTime', $startTime) |
||
85 | ->andWhere("cm.createTime <= :endTime")->setParameter('endTime', $endTime) |
||
86 | ->getQuery() |
||
87 | ->getSingleResult(); |
||
88 | |||
89 | return (isset($result['waitTime'])) ? $result['waitTime'] : 0; |
||
90 | } |
||
91 | |||
92 | public function getAvgWaitTime(\DateTime $startTime, \DateTime $endTime): int |
||
93 | { |
||
94 | $result = $this->createQueryBuilder('cm') |
||
95 | ->select('AVG(cm.runTime) as waitTime') |
||
96 | ->where("cm.createTime > :startTime")->setParameter('startTime', $startTime) |
||
97 | ->andWhere("cm.createTime <= :endTime")->setParameter('endTime', $endTime) |
||
98 | ->getQuery() |
||
99 | ->getSingleResult(); |
||
100 | |||
101 | return (isset($result['waitTime'])) ? $result['waitTime'] : 0; |
||
102 | } |
||
103 | |||
104 | public function getOldExecutions(\DateTime $time): iterable |
||
105 | { |
||
106 | return $this->createQueryBuilder('cm') |
||
107 | ->where("cm.createTime < :time")->setParameter('time', $time)->getQuery()->toIterable(); |
||
108 | } |
||
109 | } |
||
110 | |||
111 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths