Add check for orphaned subscriptions

[MAILPOET-1587]
This commit is contained in:
Rostislav Wolny
2024-08-01 13:45:33 +02:00
committed by Aschepikov
parent 0d7898b3a5
commit fe66e31b5f
4 changed files with 65 additions and 0 deletions

View File

@@ -8,11 +8,13 @@ class DataInconsistencyController {
const ORPHANED_SENDING_TASKS = 'orphaned_sending_tasks';
const ORPHANED_SENDING_TASK_SUBSCRIBERS = 'orphaned_sending_task_subscribers';
const SENDING_QUEUE_WITHOUT_NEWSLETTER = 'sending_queue_without_newsletter';
const ORPHANED_SUBSCRIPTIONS = 'orphaned_subscriptions';
const SUPPORTED_INCONSISTENCY_CHECKS = [
self::ORPHANED_SENDING_TASKS,
self::ORPHANED_SENDING_TASK_SUBSCRIBERS,
self::SENDING_QUEUE_WITHOUT_NEWSLETTER,
self::ORPHANED_SUBSCRIPTIONS,
];
private DataInconsistencyRepository $repository;
@@ -28,6 +30,7 @@ class DataInconsistencyController {
self::ORPHANED_SENDING_TASKS => $this->repository->getOrphanedSendingTasksCount(),
self::ORPHANED_SENDING_TASK_SUBSCRIBERS => $this->repository->getOrphanedScheduledTasksSubscribersCount(),
self::SENDING_QUEUE_WITHOUT_NEWSLETTER => $this->repository->getSendingQueuesWithoutNewsletterCount(),
self::ORPHANED_SUBSCRIPTIONS => $this->repository->getOrphanedSubscriptionsCount(),
];
$result['total'] = array_sum($result);
return $result;
@@ -43,6 +46,8 @@ class DataInconsistencyController {
$this->repository->cleanupOrphanedScheduledTaskSubscribers();
} elseif ($inconsistency === self::SENDING_QUEUE_WITHOUT_NEWSLETTER) {
$this->repository->cleanupSendingQueuesWithoutNewsletter();
} elseif ($inconsistency === self::ORPHANED_SUBSCRIPTIONS) {
$this->repository->cleanupOrphanedSubscriptions();
}
}
}