Skip to content

Commit

Permalink
Adds faster calculation of expected recipients
Browse files Browse the repository at this point in the history
commit d641372
Author: bencroker <[email protected]>
Date:   Fri Mar 8 20:24:19 2024 -0600

    Revert the fix, back to square 1

commit cffeae2
Merge: 6a3f170 b58bda0
Author: Ben Croker <[email protected]>
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 6a3f170
Author: bencroker <[email protected]>
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 b58bda0
Author: Ben Croker <[email protected]>
Date:   Fri Mar 8 19:31:31 2024 -0600

    Remove batching, code cleanup

commit d267fbe
Author: Ben Croker <[email protected]>
Date:   Fri Mar 8 18:54:44 2024 -0600

    Revert changes

commit 57e808a
Merge: 4b83e5c f289a4b
Author: Ben Croker <[email protected]>
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 db87912
Author: Kenneth Ormandy <[email protected]>
Date:   Fri Mar 8 12:46:58 2024 -0800

    Adds batch query when querying regular sendout recipients

commit 11cfb80
Author: Kenneth Ormandy <[email protected]>
Date:   Fri Mar 8 12:44:26 2024 -0800

    Adds faster calculation of expected recipients for regular sendouts
  • Loading branch information
bencroker committed Mar 9, 2024
1 parent f289a4b commit 8b791ce
Showing 1 changed file with 31 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/services/SendoutsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit 8b791ce

Please sign in to comment.