Remove global count methods.
In the previous commit, we removed the global count for our output. This commit removes the logic as the only places where it was used was in recalculating the cache and since the last commit, we do not use this value anymore [MAILPOET-4487]
This commit is contained in:
@ -436,9 +436,6 @@ class Settings extends APIEndpoint {
|
||||
$segments = $this->segmentsRepository->findAll();
|
||||
foreach ($segments as $segment) {
|
||||
$this->subscribersCountsController->recalculateSegmentStatisticsCache($segment);
|
||||
if ($segment->isStatic()) {
|
||||
$this->subscribersCountsController->recalculateSegmentGlobalStatusStatisticsCache($segment);
|
||||
}
|
||||
}
|
||||
$this->subscribersCountsController->recalculateSubscribersWithoutSegmentStatisticsCache();
|
||||
// remove redundancies from cache
|
||||
|
@ -7,7 +7,6 @@ use MailPoetVendor\Carbon\Carbon;
|
||||
|
||||
class TransientCache {
|
||||
public const SUBSCRIBERS_STATISTICS_COUNT_KEY = 'mailpoet_subscribers_statistics_count_cache';
|
||||
public const SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY = 'mailpoet_subscribers_statistics_count_global_status_cache';
|
||||
public const SUBSCRIBERS_HOMEPAGE_STATISTICS_COUNT_KEY = 'mailpoet_subscribers_statistics_count_homepage_cache';
|
||||
|
||||
private $cacheEnabled;
|
||||
@ -68,7 +67,6 @@ class TransientCache {
|
||||
|
||||
public function invalidateAllItems(): void {
|
||||
$this->invalidateItems(self::SUBSCRIBERS_STATISTICS_COUNT_KEY);
|
||||
$this->invalidateItems(self::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY);
|
||||
$this->invalidateItems(self::SUBSCRIBERS_HOMEPAGE_STATISTICS_COUNT_KEY);
|
||||
}
|
||||
|
||||
|
@ -62,9 +62,6 @@ class SubscribersCountCacheRecalculation extends SimpleWorker {
|
||||
if ($item === null || !isset($item['created_at']) || $now->diffInMinutes($item['created_at']) > self::EXPIRATION_IN_MINUTES) {
|
||||
if ($segment) {
|
||||
$this->subscribersCountsController->recalculateSegmentStatisticsCache($segment);
|
||||
if ($segment->isStatic()) {
|
||||
$this->subscribersCountsController->recalculateSegmentGlobalStatusStatisticsCache($segment);
|
||||
}
|
||||
} else {
|
||||
$this->subscribersCountsController->recalculateSubscribersWithoutSegmentStatisticsCache();
|
||||
}
|
||||
|
@ -71,14 +71,6 @@ class SubscribersCountsController {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSegmentGlobalStatusStatisticsCount(SegmentEntity $segment): array {
|
||||
$result = $this->getCacheItem(TransientCache::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY, (int)$segment->getId())['item'] ?? null;
|
||||
if (!$result) {
|
||||
$result = $this->recalculateSegmentGlobalStatusStatisticsCache($segment);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSegmentStatisticsCountById(int $segmentId): array {
|
||||
$result = $this->getCacheItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $segmentId)['item'] ?? null;
|
||||
if (!$result) {
|
||||
@ -99,16 +91,6 @@ class SubscribersCountsController {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function recalculateSegmentGlobalStatusStatisticsCache(SegmentEntity $segment): array {
|
||||
$result = $this->segmentSubscribersRepository->getSubscribersGlobalStatusStatisticsCount($segment);
|
||||
$this->setCacheItem(
|
||||
TransientCache::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY,
|
||||
$result,
|
||||
(int)$segment->getId()
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function recalculateSegmentStatisticsCache(SegmentEntity $segment): array {
|
||||
$result = $this->segmentSubscribersRepository->getSubscribersStatisticsCount($segment);
|
||||
$this->setCacheItem(
|
||||
@ -151,11 +133,6 @@ class SubscribersCountsController {
|
||||
$this->transientCache->invalidateItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $id);
|
||||
}
|
||||
}
|
||||
foreach ($this->transientCache->getItems(TransientCache::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY) as $id => $item) {
|
||||
if (!in_array($id, $segmentIds)) {
|
||||
$this->transientCache->invalidateItem(TransientCache::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY, $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user