From 8b791ceac61219a9ce525ec1d0555ac8aeea7adb Mon Sep 17 00:00:00 2001 From: bencroker Date: Sat, 9 Mar 2024 08:54:59 -0600 Subject: [PATCH] Adds faster calculation of expected recipients commit d641372c363ff123c8468c7af5a40909eae95d94 Author: bencroker Date: Fri Mar 8 20:24:19 2024 -0600 Revert the fix, back to square 1 commit cffeae2f59301505e09044d0741cf9c5804c918d Merge: 6a3f170 b58bda0 Author: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Fri Mar 8 19:42:20 2024 -0600 Merge pull request #456 from kennethormandy/contacts-batch-query Updates contacts query for large lists commit 6a3f1707455ec81d138ada0e976a507884df412f Author: bencroker Date: Fri Mar 8 19:36:05 2024 -0600 Fix too many parameters MySQL acccepts at most 65535 parameters, so it is important to use a `where` clause here. commit b58bda0248fe23a7f65b14cce19f4df079b0b19b Author: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Fri Mar 8 19:31:31 2024 -0600 Remove batching, code cleanup commit d267fbeead51113e4a7a160beeb7650d1598f661 Author: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Fri Mar 8 18:54:44 2024 -0600 Revert changes commit 57e808a7af590ed3f79a98b0eef157397eac7b45 Merge: 4b83e5c f289a4b Author: Ben Croker <57572400+bencroker@users.noreply.github.com> Date: Fri Mar 8 18:45:24 2024 -0600 Merge pull request #455 from kennethormandy/bugfix/missing-preflight-twig-variables Fixes missing memory limit and time limit Twig variables commit db8791288a2c7069b46c0055f0ab539358b3e3b7 Author: Kenneth Ormandy Date: Fri Mar 8 12:46:58 2024 -0800 Adds batch query when querying regular sendout recipients commit 11cfb80c9d82311364ceb9c766f444259e136395 Author: Kenneth Ormandy Date: Fri Mar 8 12:44:26 2024 -0800 Adds faster calculation of expected recipients for regular sendouts --- src/services/SendoutsService.php | 37 ++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/services/SendoutsService.php b/src/services/SendoutsService.php index ee27ed45..5dcbadbb 100755 --- a/src/services/SendoutsService.php +++ b/src/services/SendoutsService.php @@ -130,7 +130,13 @@ public function getPendingRecipients(SendoutElement $sendout): array */ public function getPendingRecipientCount(SendoutElement $sendout): int { - return count($this->getPendingRecipients($sendout)) - $sendout->failures; + if ($sendout->sendoutType === 'regular') { + $count = count($this->_getPendingRecipientsStandardIds($sendout)); + } else { + $count = count($this->getPendingRecipients($sendout)); + } + + return $count - $sendout->failures; } /** @@ -588,16 +594,24 @@ private function _getSentRecipientsQuery(SendoutElement $sendout, bool $todayOnl } /** - * Returns the standard sendout's pending contact IDs. + * Returns the standard sendout’s base query condition. */ - private function _getPendingRecipientsStandard(SendoutElement $sendout): array + private function _getPendingRecipientsStandardBaseCondition(SendoutElement $sendout): array { - App::maxPowerCaptain(); - - $baseCondition = [ + return [ 'mailingListId' => $sendout->mailingListIds, 'subscriptionStatus' => 'subscribed', ]; + } + + /** + * Returns the standard sendout’s pending contact IDs. + */ + private function _getPendingRecipientsStandardIds(SendoutElement $sendout): array + { + App::maxPowerCaptain(); + + $baseCondition = $this->_getPendingRecipientsStandardBaseCondition($sendout); // Get contacts subscribed to sendout's mailing lists $query = ContactMailingListRecord::find() @@ -633,6 +647,17 @@ private function _getPendingRecipientsStandard(SendoutElement $sendout): array } } + return $contactIds; + } + + /** + * Returns the standard sendout’s pending contacts. + */ + private function _getPendingRecipientsStandard(SendoutElement $sendout): array + { + $baseCondition = $this->_getPendingRecipientsStandardBaseCondition($sendout); + $contactIds = $this->_getPendingRecipientsStandardIds($sendout); + // Get recipients as array return ContactMailingListRecord::find() ->select(['contactId', 'min([[mailingListId]]) as mailingListId', 'min([[subscribed]]) as subscribed'])