Skip to content

Commit 3beaa0f

Browse files
authored
Exclude inactive tasks from health check
If a task is set to inactive, the status always reports as unhealthy, because inactive tasks may not running for a long period. By excluding inactive tasks, the state can be reported correctly.
1 parent 9bae12f commit 3beaa0f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/Components/Health/Checker/TaskChecker.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
99
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
1010
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter;
11+
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter;
12+
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
13+
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskDefinition;
1114

1215
class TaskChecker implements CheckerInterface
1316
{
@@ -35,6 +38,12 @@ public function collect(HealthCollection $collection): void
3538
['lte' => $date->format(\DATE_ATOM)]
3639
)
3740
);
41+
$criteria->addFilter(new NotFilter(
42+
NotFilter::CONNECTION_AND,
43+
[
44+
new EqualsFilter('status', ScheduledTaskDefinition::STATUS_INACTIVE)
45+
]
46+
));
3847

3948
$oldTasks = $this->scheduledTaskRepository
4049
->searchIds($criteria, Context::createDefaultContext())->getIds();

0 commit comments

Comments
 (0)