From eb93dfc76b52b0b5e9d5218078162a6aba2f7099 Mon Sep 17 00:00:00 2001 From: bencroker Date: Tue, 8 Oct 2024 16:18:39 +0200 Subject: [PATCH] Exclude drafts when calculating pending recipients --- CHANGELOG.md | 3 ++- src/records/ContactMailingListRecord.php | 4 +++- src/services/SendoutsService.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af3d328a..d9449118 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ # Release Notes for Campaign -## 3.5.3 - Unreleased +## 3.5.3 - 2024-10-08 ### Fixed +- Fixed the calculation of pending recipients to not include drafts. - Fixed the sendout status colour indicators on sendout preview pages. ## 3.5.2 - 2024-10-04 diff --git a/src/records/ContactMailingListRecord.php b/src/records/ContactMailingListRecord.php index 1ba48c00..aeb10d39 100644 --- a/src/records/ContactMailingListRecord.php +++ b/src/records/ContactMailingListRecord.php @@ -41,11 +41,13 @@ public static function tableName(): string */ public static function find(): ActiveQuery { - // Create a subquery to ensure only contacts and mailing lists that are not deleted are returned + // Create a subquery to ensure only contacts and mailing lists that are not drafts not deleted are returned $subquery = parent::find() ->innerJoin(Table::ELEMENTS . ' contactElement', '[[contactElement.id]] = [[contactId]]') ->innerJoin(Table::ELEMENTS . ' mailingListElement', '[[mailingListElement.id]] = [[mailingListId]]') ->where([ + 'contactElement.draftId' => null, + 'mailingListElement.draftId' => null, 'contactElement.dateDeleted' => null, 'mailingListElement.dateDeleted' => null, ]); diff --git a/src/services/SendoutsService.php b/src/services/SendoutsService.php index 03ab675f..b1d52fea 100755 --- a/src/services/SendoutsService.php +++ b/src/services/SendoutsService.php @@ -606,7 +606,7 @@ private function getPendingRecipientsStandardIds(SendoutElement $sendout): array // Get contacts subscribed to sendout’s mailing lists $query = ContactMailingListRecord::find() ->select(['contactId']) - ->andWhere($baseCondition); + ->where($baseCondition); // Ensure contacts have not complained, bounced, or been blocked (in contact record) $query->innerJoin(ContactRecord::tableName() . ' contact', '[[contact.id]] = [[contactId]]')