Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSP-178 - Fix for scheduled tasks v4 #96

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
use Shopware\Core\Framework\Api\Context\SystemSource;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Symfony\Component\Cache\Adapter\TagAwareAdapterInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler(handles: DailyProductSyncScheduledTask::class)]
class DailyProductSyncScheduledTaskHandler extends ScheduledTaskHandler
{
private const LAST_EXECUTION_TIME_CONFIG = 'dailySyncLastTime';
Expand All @@ -36,14 +37,6 @@ public function __construct(
parent::__construct($scheduledTaskRepository);
}

/**
* @return ScheduledTask[]
*/
public static function getHandledMessages(): iterable
{
return [DailyProductSyncScheduledTask::class];
}

public function run(): void
{
if ($this->isTimeToRunJob()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
use Nosto\Scheduler\Model\Job\GeneratingHandlerInterface;
use Nosto\Scheduler\Model\JobScheduler;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Shopware\Core\Framework\Uuid\Uuid;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;

#[AsMessageHandler(handles: EntityChangelogScheduledTask::class)]
class EntityChangelogScheduledTaskHandler extends ScheduledTaskHandler implements GeneratingHandlerInterface
{
public function __construct(
Expand All @@ -21,14 +22,6 @@ public function __construct(
parent::__construct($scheduledTaskRepository);
}

/**
* @return ScheduledTask[]
*/
public static function getHandledMessages(): iterable
{
return [EntityChangelogScheduledTask::class];
}

public function run(): void
{
$jobMessage = new EntityChangelogSyncMessage(Uuid::randomHex());
Expand Down
11 changes: 2 additions & 9 deletions src/Service/ScheduledTask/OldJobCleanupScheduledTaskHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\ContainsFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Throwable;

#[AsMessageHandler(handles: OldJobCleanupScheduledTask::class)]
class OldJobCleanupScheduledTaskHandler extends ScheduledTaskHandler
{
public function __construct(
Expand All @@ -31,14 +32,6 @@ public function __construct(
parent::__construct($scheduledTaskRepository);
}

/**
* @return ScheduledTask[]
*/
public static function getHandledMessages(): iterable
{
return [OldJobCleanupScheduledTask::class];
}

public function run(): void
{
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
use Psr\Log\LoggerInterface;
use Shopware\Core\Defaults;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTask;
use Shopware\Core\Framework\MessageQueue\ScheduledTask\ScheduledTaskHandler;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Throwable;

#[AsMessageHandler(handles: OldNostoDataCleanupScheduledTask::class)]
class OldNostoDataCleanupScheduledTaskHandler extends ScheduledTaskHandler
{
public function __construct(
Expand All @@ -25,14 +26,6 @@ public function __construct(
parent::__construct($scheduledTaskRepository);
}

/**
* @return ScheduledTask[]
*/
public static function getHandledMessages(): iterable
{
return [OldNostoDataCleanupScheduledTask::class];
}

public function run(): void
{
try {
Expand Down
Loading