1 | <?php |
||
2 | |||
3 | namespace Dtc\QueueBundle\ORM; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
0 ignored issues
–
show
|
|||
6 | use Dtc\GridBundle\Grid\Column\GridColumn; |
||
0 ignored issues
–
show
The type
Dtc\GridBundle\Grid\Column\GridColumn 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 Dtc\GridBundle\Grid\Source\ColumnExtractionTrait; |
||
0 ignored issues
–
show
The type
Dtc\GridBundle\Grid\Source\ColumnExtractionTrait 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 ![]() |
|||
8 | use Dtc\GridBundle\Grid\Source\EntityGridSource; |
||
0 ignored issues
–
show
The type
Dtc\GridBundle\Grid\Source\EntityGridSource 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 ![]() |
|||
9 | use Dtc\QueueBundle\Model\BaseJob; |
||
10 | |||
11 | class LiveJobsGridSource extends EntityGridSource |
||
12 | { |
||
13 | 1 | use ColumnExtractionTrait; |
|
14 | protected $jobManager; |
||
15 | protected $running = false; |
||
16 | private $columnSource; |
||
17 | |||
18 | 2 | public function getId() |
|
19 | { |
||
20 | 2 | return 'dtc_queue.grid_source.jobs_'.($this->isRunning() ? 'running' : 'waiting').'.orm'; |
|
21 | } |
||
22 | |||
23 | 10 | public function __construct(JobManager $jobManager) |
|
24 | { |
||
25 | 10 | $this->jobManager = $jobManager; |
|
26 | /** @var EntityManager $entityManager */ |
||
27 | 10 | $entityManager = $jobManager->getObjectManager(); |
|
28 | 10 | parent::__construct($entityManager, $jobManager->getJobClass()); |
|
29 | 10 | } |
|
30 | |||
31 | /** |
||
32 | * @param bool $flag |
||
33 | */ |
||
34 | 10 | public function setRunning($flag) |
|
35 | { |
||
36 | 10 | $this->running = $flag; |
|
37 | 10 | } |
|
38 | |||
39 | 3 | public function isRunning() |
|
40 | { |
||
41 | 3 | return $this->running; |
|
42 | } |
||
43 | |||
44 | public function setColumnSource(\Dtc\GridBundle\Grid\Source\ColumnSource $columnSource) |
||
0 ignored issues
–
show
The type
Dtc\GridBundle\Grid\Source\ColumnSource 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 ![]() |
|||
45 | { |
||
46 | $this->columnSource = $columnSource; |
||
47 | } |
||
48 | |||
49 | 1 | protected function getRunningQueryBuilder() |
|
50 | { |
||
51 | /** @var EntityManager $entityManager */ |
||
52 | 1 | $entityManager = $this->jobManager->getObjectManager(); |
|
53 | 1 | $queryBuilder = $entityManager->createQueryBuilder()->add('select', 'j'); |
|
54 | 1 | $queryBuilder->from($this->jobManager->getJobClass(), 'j'); |
|
55 | 1 | $queryBuilder->where('j.status = :status')->setParameter(':status', BaseJob::STATUS_RUNNING); |
|
56 | 1 | $queryBuilder->orderBy('j.startedAt', 'DESC'); |
|
57 | 1 | $queryBuilder->setFirstResult($this->offset) |
|
58 | 1 | ->setMaxResults($this->limit); |
|
59 | |||
60 | 1 | return $queryBuilder; |
|
61 | } |
||
62 | |||
63 | 1 | protected function getQueryBuilder() |
|
64 | { |
||
65 | 1 | if ($this->isRunning()) { |
|
66 | 1 | return $this->getRunningQueryBuilder(); |
|
67 | } |
||
68 | |||
69 | 1 | $queryBuilder = $this->jobManager->getJobQueryBuilder(); |
|
70 | 1 | $queryBuilder->add('select', 'j'); |
|
71 | 1 | $queryBuilder->setFirstResult($this->offset) |
|
72 | 1 | ->setMaxResults($this->limit); |
|
73 | |||
74 | 1 | return $queryBuilder; |
|
75 | } |
||
76 | |||
77 | 3 | public function setColumns($columns) |
|
78 | { |
||
79 | 3 | if ($columns) { |
|
80 | 3 | foreach ($columns as $column) { |
|
81 | 3 | if ($column instanceof GridColumn) { |
|
82 | 3 | $column->setOption('sortable', false); |
|
83 | } |
||
84 | } |
||
85 | } |
||
86 | |||
87 | 3 | parent::setColumns($columns); |
|
88 | 3 | } |
|
89 | |||
90 | 3 | public function getColumns() |
|
91 | { |
||
92 | 3 | if ($columns = parent::getColumns()) { |
|
93 | 2 | return $columns; |
|
94 | } |
||
95 | |||
96 | 3 | if (!$this->columnSource) { |
|
97 | 3 | $this->autoDiscoverColumns(); |
|
98 | |||
99 | 3 | return parent::getColumns(); |
|
100 | } |
||
101 | |||
102 | $columnSourceInfo = $this->columnSource->getColumnSourceInfo($this->objectManager, 'Dtc\QueueBundle\Entity\Job', false); |
||
103 | $this->setColumns($columnSourceInfo->columns); |
||
104 | $this->setDefaultSort($columnSourceInfo->sort); |
||
105 | $this->setIdColumn($columnSourceInfo->idColumn); |
||
106 | |||
107 | return parent::getColumns(); |
||
108 | } |
||
109 | |||
110 | 3 | public function getDefaultSort() |
|
111 | { |
||
112 | 3 | return null; |
|
113 | } |
||
114 | |||
115 | 1 | public function getCount() |
|
116 | { |
||
117 | 1 | $qb = $this->getQueryBuilder(); |
|
118 | 1 | $qb->resetDQLPart('orderBy'); |
|
119 | 1 | $qb->add('select', 'count(j)') |
|
120 | 1 | ->setFirstResult(null) |
|
121 | 1 | ->setMaxResults(null); |
|
122 | |||
123 | 1 | return $qb->getQuery() |
|
124 | 1 | ->getSingleScalarResult(); |
|
125 | } |
||
126 | } |
||
127 |
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