Simplify the query to calculate lifetime emails
Get max and count of subscribers in the query. [MAILPOET-4177]
This commit is contained in:
@ -107,10 +107,12 @@ class SubscribersEmailCountsController {
|
|||||||
|
|
||||||
private function countAndMaxOfSubscribersInRange(int $startId, int $batchSize): array {
|
private function countAndMaxOfSubscribersInRange(int $startId, int $batchSize): array {
|
||||||
$result = $this->entityManager->getConnection()->executeQuery("
|
$result = $this->entityManager->getConnection()->executeQuery("
|
||||||
SELECT s.id FROM {$this->subscribersTable} as s
|
SELECT COUNT(ids.id) as count, COALESCE(MAX(ids.id), 0) as max FROM (
|
||||||
WHERE s.id >= :startId
|
SELECT s.id FROM {$this->subscribersTable} as s
|
||||||
ORDER BY s.id
|
WHERE s.id >= :startId
|
||||||
LIMIT :batchSize
|
ORDER BY s.id
|
||||||
|
LIMIT :batchSize
|
||||||
|
) ids
|
||||||
",
|
",
|
||||||
[
|
[
|
||||||
'startId' => $startId,
|
'startId' => $startId,
|
||||||
@ -124,16 +126,6 @@ class SubscribersEmailCountsController {
|
|||||||
|
|
||||||
$subscribersInRange = $result->fetchAllAssociative();
|
$subscribersInRange = $result->fetchAllAssociative();
|
||||||
|
|
||||||
$countSubscribersInRange = count(array_map(
|
return [$subscribersInRange[0]['count'], $subscribersInRange[0]['max']];
|
||||||
function ($id) {
|
|
||||||
return (int)$id['id'];
|
|
||||||
},
|
|
||||||
$subscribersInRange
|
|
||||||
));
|
|
||||||
|
|
||||||
if (!$countSubscribersInRange) {
|
|
||||||
return [0,0];
|
|
||||||
}
|
|
||||||
return [$countSubscribersInRange,$subscribersInRange[$countSubscribersInRange - 1]['id']];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1106,11 +1106,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: ../../lib/Subscribers/InactiveSubscribersController.php
|
path: ../../lib/Subscribers/InactiveSubscribersController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot cast mixed to int\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../lib/Subscribers/SubscribersEmailCountsController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot cast mixed to int\\.$#"
|
message: "#^Cannot cast mixed to int\\.$#"
|
||||||
count: 3
|
count: 3
|
||||||
|
@ -1106,11 +1106,6 @@ parameters:
|
|||||||
count: 2
|
count: 2
|
||||||
path: ../../lib/Subscribers/InactiveSubscribersController.php
|
path: ../../lib/Subscribers/InactiveSubscribersController.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Cannot cast mixed to int\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../lib/Subscribers/SubscribersEmailCountsController.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Cannot cast mixed to int\\.$#"
|
message: "#^Cannot cast mixed to int\\.$#"
|
||||||
count: 3
|
count: 3
|
||||||
|
Reference in New Issue
Block a user