update
This commit is contained in:
29
src/Modules/Cron/AutomationHistoryCleanupHandler.php
Normal file
29
src/Modules/Cron/AutomationHistoryCleanupHandler.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Cron;
|
||||
|
||||
use App\Modules\Automation\AutomationExecutionLogRepository;
|
||||
|
||||
final class AutomationHistoryCleanupHandler
|
||||
{
|
||||
public function __construct(private readonly AutomationExecutionLogRepository $repository)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function handle(array $payload): array
|
||||
{
|
||||
$days = max(1, (int) ($payload['days'] ?? 30));
|
||||
$deletedCount = $this->repository->purgeOlderThanDays($days);
|
||||
|
||||
return [
|
||||
'ok' => true,
|
||||
'days' => $days,
|
||||
'deleted_count' => $deletedCount,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use App\Core\View\Template;
|
||||
use App\Modules\Accounting\ReceiptRepository;
|
||||
use App\Modules\Automation\AutomationRepository;
|
||||
use App\Modules\Automation\AutomationService;
|
||||
use App\Modules\Automation\AutomationExecutionLogRepository;
|
||||
use App\Modules\Email\AttachmentGenerator;
|
||||
use App\Modules\Email\EmailSendingService;
|
||||
use App\Modules\Email\VariableResolver;
|
||||
@@ -163,6 +164,9 @@ final class CronHandlerFactory
|
||||
new ShipmentPackageRepository($this->db),
|
||||
$automationService
|
||||
),
|
||||
'automation_history_cleanup' => new AutomationHistoryCleanupHandler(
|
||||
new AutomationExecutionLogRepository($this->db)
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -170,6 +174,7 @@ final class CronHandlerFactory
|
||||
private function buildAutomationService(OrdersRepository $ordersRepository): AutomationService
|
||||
{
|
||||
$automationRepository = new AutomationRepository($this->db);
|
||||
$executionLogRepository = new AutomationExecutionLogRepository($this->db);
|
||||
$companySettingsRepository = new CompanySettingsRepository($this->db);
|
||||
$emailTemplateRepository = new EmailTemplateRepository($this->db);
|
||||
$emailMailboxRepository = new EmailMailboxRepository(
|
||||
@@ -186,7 +191,7 @@ final class CronHandlerFactory
|
||||
$ordersRepository,
|
||||
$emailTemplateRepository,
|
||||
$emailMailboxRepository,
|
||||
new VariableResolver(),
|
||||
new VariableResolver(new ShipmentPackageRepository($this->db)),
|
||||
new AttachmentGenerator(
|
||||
new ReceiptRepository($this->db),
|
||||
new ReceiptConfigRepository($this->db),
|
||||
@@ -196,6 +201,7 @@ final class CronHandlerFactory
|
||||
|
||||
return new AutomationService(
|
||||
$automationRepository,
|
||||
$executionLogRepository,
|
||||
$emailService,
|
||||
$ordersRepository,
|
||||
$companySettingsRepository,
|
||||
|
||||
Reference in New Issue
Block a user