|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Module\Tick\Colony; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use Stu\Module\Logging\LoggerEnum; |
|
|
|
|
|
|
9
|
|
|
use Stu\Module\Logging\LoggerUtilFactoryInterface; |
|
10
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
|
11
|
|
|
use Stu\Module\Tick\AbstractTickManager; |
|
12
|
|
|
use Stu\Module\Tick\Lock\LockManagerInterface; |
|
13
|
|
|
use Stu\Module\Tick\Lock\LockTypeEnum; |
|
14
|
|
|
use Stu\Orm\Repository\ColonyRepositoryInterface; |
|
15
|
|
|
use Ubench; |
|
16
|
|
|
|
|
17
|
|
|
final class ColonyTickManager extends AbstractTickManager implements ColonyTickManagerInterface |
|
18
|
|
|
{ |
|
19
|
|
|
private LoggerUtilInterface $loggerUtil; |
|
20
|
|
|
|
|
21
|
1 |
|
public function __construct( |
|
22
|
|
|
private ColonyTickInterface $colonyTick, |
|
23
|
|
|
private ColonyRepositoryInterface $colonyRepository, |
|
24
|
|
|
private LockManagerInterface $lockManager, |
|
25
|
|
|
LoggerUtilFactoryInterface $loggerUtilFactory, |
|
26
|
|
|
private Ubench $benchmark |
|
27
|
|
|
) { |
|
28
|
1 |
|
$this->loggerUtil = $loggerUtilFactory->getLoggerUtil(); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
1 |
|
#[Override] |
|
32
|
|
|
public function work(int $batchGroup, int $batchGroupCount): void |
|
33
|
|
|
{ |
|
34
|
1 |
|
$this->setLock($batchGroup); |
|
35
|
|
|
try { |
|
36
|
1 |
|
$entityCount = $this->colonyLoop($batchGroup, $batchGroupCount); |
|
37
|
|
|
|
|
38
|
|
|
$this->loggerUtil->init(sprintf( |
|
39
|
|
|
'COLOTICK_%dof%d', |
|
40
|
|
|
$batchGroup, |
|
41
|
|
|
$batchGroupCount |
|
42
|
|
|
), LoggerEnum::LEVEL_WARNING); |
|
43
|
|
|
$this->logBenchmarkResult($entityCount); |
|
44
|
|
|
} finally { |
|
45
|
1 |
|
$this->clearLock($batchGroup); |
|
46
|
|
|
} |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
1 |
|
private function colonyLoop(int $batchGroup, int $batchGroupCount): int |
|
50
|
|
|
{ |
|
51
|
1 |
|
$colonyList = $this->colonyRepository->getByBatchGroup($batchGroup, $batchGroupCount); |
|
52
|
|
|
|
|
53
|
|
|
$entityCount = 0; |
|
54
|
|
|
foreach ($colonyList as $colony) { |
|
55
|
|
|
//echo "Processing Colony ".$colony->getId()." at ".microtime()."\n"; |
|
56
|
|
|
|
|
57
|
|
|
//handle colony only if vacation mode not active |
|
58
|
|
|
if (!$colony->getUser()->isVacationRequestOldEnough()) { |
|
59
|
|
|
$this->colonyTick->work($colony); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
$entityCount++; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $entityCount; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
1 |
|
private function setLock(int $batchGroupId): void |
|
69
|
|
|
{ |
|
70
|
1 |
|
$this->lockManager->setLock($batchGroupId, LockTypeEnum::COLONY_GROUP); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
private function clearLock(int $batchGroupId): void |
|
74
|
|
|
{ |
|
75
|
1 |
|
$this->lockManager->clearLock($batchGroupId, LockTypeEnum::COLONY_GROUP); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
#[Override] |
|
79
|
|
|
protected function getBenchmark(): Ubench |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->benchmark; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
#[Override] |
|
85
|
|
|
protected function getLoggerUtil(): LoggerUtilInterface |
|
86
|
|
|
{ |
|
87
|
|
|
return $this->loggerUtil; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
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