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();
|
$segments = $this->segmentsRepository->findAll();
|
||||||
foreach ($segments as $segment) {
|
foreach ($segments as $segment) {
|
||||||
$this->subscribersCountsController->recalculateSegmentStatisticsCache($segment);
|
$this->subscribersCountsController->recalculateSegmentStatisticsCache($segment);
|
||||||
if ($segment->isStatic()) {
|
|
||||||
$this->subscribersCountsController->recalculateSegmentGlobalStatusStatisticsCache($segment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->subscribersCountsController->recalculateSubscribersWithoutSegmentStatisticsCache();
|
$this->subscribersCountsController->recalculateSubscribersWithoutSegmentStatisticsCache();
|
||||||
// remove redundancies from cache
|
// remove redundancies from cache
|
||||||
|
@ -7,7 +7,6 @@ use MailPoetVendor\Carbon\Carbon;
|
|||||||
|
|
||||||
class TransientCache {
|
class TransientCache {
|
||||||
public const SUBSCRIBERS_STATISTICS_COUNT_KEY = 'mailpoet_subscribers_statistics_count_cache';
|
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';
|
public const SUBSCRIBERS_HOMEPAGE_STATISTICS_COUNT_KEY = 'mailpoet_subscribers_statistics_count_homepage_cache';
|
||||||
|
|
||||||
private $cacheEnabled;
|
private $cacheEnabled;
|
||||||
@ -68,7 +67,6 @@ class TransientCache {
|
|||||||
|
|
||||||
public function invalidateAllItems(): void {
|
public function invalidateAllItems(): void {
|
||||||
$this->invalidateItems(self::SUBSCRIBERS_STATISTICS_COUNT_KEY);
|
$this->invalidateItems(self::SUBSCRIBERS_STATISTICS_COUNT_KEY);
|
||||||
$this->invalidateItems(self::SUBSCRIBERS_GLOBAL_STATUS_STATISTICS_COUNT_KEY);
|
|
||||||
$this->invalidateItems(self::SUBSCRIBERS_HOMEPAGE_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 ($item === null || !isset($item['created_at']) || $now->diffInMinutes($item['created_at']) > self::EXPIRATION_IN_MINUTES) {
|
||||||
if ($segment) {
|
if ($segment) {
|
||||||
$this->subscribersCountsController->recalculateSegmentStatisticsCache($segment);
|
$this->subscribersCountsController->recalculateSegmentStatisticsCache($segment);
|
||||||
if ($segment->isStatic()) {
|
|
||||||
$this->subscribersCountsController->recalculateSegmentGlobalStatusStatisticsCache($segment);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$this->subscribersCountsController->recalculateSubscribersWithoutSegmentStatisticsCache();
|
$this->subscribersCountsController->recalculateSubscribersWithoutSegmentStatisticsCache();
|
||||||
}
|
}
|
||||||
|
@ -71,14 +71,6 @@ class SubscribersCountsController {
|
|||||||
return $result;
|
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 {
|
public function getSegmentStatisticsCountById(int $segmentId): array {
|
||||||
$result = $this->getCacheItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $segmentId)['item'] ?? null;
|
$result = $this->getCacheItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $segmentId)['item'] ?? null;
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@ -99,16 +91,6 @@ class SubscribersCountsController {
|
|||||||
return $result;
|
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 {
|
public function recalculateSegmentStatisticsCache(SegmentEntity $segment): array {
|
||||||
$result = $this->segmentSubscribersRepository->getSubscribersStatisticsCount($segment);
|
$result = $this->segmentSubscribersRepository->getSubscribersStatisticsCount($segment);
|
||||||
$this->setCacheItem(
|
$this->setCacheItem(
|
||||||
@ -151,11 +133,6 @@ class SubscribersCountsController {
|
|||||||
$this->transientCache->invalidateItem(TransientCache::SUBSCRIBERS_STATISTICS_COUNT_KEY, $id);
|
$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