From 6b4767618d310e3acbfda40f596f2d884b5cf3ed Mon Sep 17 00:00:00 2001 From: scottshipman Date: Mon, 17 Dec 2018 15:57:12 -0500 Subject: [PATCH 1/2] [ENG-598] 1) Dont export / prevent warning when no leads to export --- Controller/ExportController.php | 4 ++++ Translations/en_US/messages.ini | 1 + 2 files changed, 5 insertions(+) diff --git a/Controller/ExportController.php b/Controller/ExportController.php index 607ff28..b2f4037 100644 --- a/Controller/ExportController.php +++ b/Controller/ExportController.php @@ -47,6 +47,10 @@ public function campaignContactsExportAction($campaignId, $dateFrom, $dateTo) list($dateFrom, $dateTo) = $this->convertDateParams($dateFrom, $dateTo); $contactIds = $this->getCampaignLeadIdsForExport($campaign->getId(), $dateFrom, $dateTo); + if (empty($contactIds)) { + return $this->notFound('mautic.campaignwatch.export.nocontacts'); + } + // adjust $size for memory vs. speed $batches = array_chunk($contactIds, 100); diff --git a/Translations/en_US/messages.ini b/Translations/en_US/messages.ini index 04877ec..3dbdf4e 100644 --- a/Translations/en_US/messages.ini +++ b/Translations/en_US/messages.ini @@ -2,3 +2,4 @@ mautic.campaignwatch.export.notfound = "Cannot Export Contact List. The campaign mautic.report.campaign.pending.actions = "Dropped Contacts and Pending Actions" mautic.campaignwatch.stat_chart.toggle.label = "Exclude Campaign Details Stats Chart" mautic.campaignwatch.stat_chart.toggle.tooltip = "Set to yes to improved perfomance of Campaign pages by excluding Campaign Statistics" +mautic.campaignwatch.export.nocontacts = "Cannot Export Contact List. There were no contacts to export." From 2edc5f3bf30b89c0b68ac25e79538b540de654aa Mon Sep 17 00:00:00 2001 From: scottshipman Date: Mon, 17 Dec 2018 16:42:07 -0500 Subject: [PATCH 2/2] [ENG-598] 2) fix date conversions and migrate to timestamps --- Controller/ExportController.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Controller/ExportController.php b/Controller/ExportController.php index b2f4037..a329b1a 100644 --- a/Controller/ExportController.php +++ b/Controller/ExportController.php @@ -116,8 +116,8 @@ public function getCampaignLeadIdsForExport($campaignId, $dateFrom, $dateTo) ->where( $q->expr()->eq('cl.manually_removed', ':false'), $q->expr()->eq('cl.campaign_id', ':campaign'), - $q->expr()->gte('cl.date_added', ':dateFrom'), - $q->expr()->lt('cl.date_added', ':dateTo') + $q->expr()->gte('cl.date_added', 'FROM_UNIXTIME(:dateFrom)'), + $q->expr()->lt('cl.date_added', 'FROM_UNIXTIME(:dateTo)') ) ->setParameter('false', false, 'boolean') ->setParameter('campaign', $campaignId) @@ -140,16 +140,14 @@ public function getCampaignLeadIdsForExport($campaignId, $dateFrom, $dateTo) */ private function convertDateParams($dateFrom, $dateTo) { - $timezone = new \DateTimeZone('UTC'); + $dateFromConverted = new \DateTime($dateFrom); - $dateFromConverted = new \DateTime($dateFrom, $timezone); - - $dateToConverted = new \DateTime($dateTo, $timezone); - $dateToConverted->modify('+1 day'); + $dateToConverted = new \DateTime($dateTo); + $dateToConverted->modify('+1 day -1 second'); return [ - $dateFromConverted->format('Y-m-d H:i:s'), - $dateToConverted->format('Y-m-d H:i:s'), + $dateFromConverted->getTimestamp(), + $dateToConverted->getTimestamp(), ]; }