From: yashodha Date: Mon, 26 Mar 2018 06:44:49 +0000 (+0530) Subject: CRM-21677 reduce unnecessary joins in mailing reports X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2a5bea53841c2e6fe7b5050cd1b126d96220461b;p=civicrm-core.git CRM-21677 reduce unnecessary joins in mailing reports --- diff --git a/CRM/Report/Form/Mailing/Bounce.php b/CRM/Report/Form/Mailing/Bounce.php index 574d1659f9..9d438b72a2 100644 --- a/CRM/Report/Form/Mailing/Bounce.php +++ b/CRM/Report/Form/Mailing/Bounce.php @@ -337,13 +337,7 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { INNER JOIN civicrm_mailing {$this->_aliases['civicrm_mailing']} ON civicrm_mailing_job.mailing_id = {$this->_aliases['civicrm_mailing']}.id "; - - if ($this->_phoneField) { - $this->_from .= " - LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} - ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND - {$this->_aliases['civicrm_phone']}.is_primary = 1 "; - } + $this->joinPhoneFromContact(); } public function where() { diff --git a/CRM/Report/Form/Mailing/Clicks.php b/CRM/Report/Form/Mailing/Clicks.php index 31e6429226..4bfa795ac8 100644 --- a/CRM/Report/Form/Mailing/Clicks.php +++ b/CRM/Report/Form/Mailing/Clicks.php @@ -293,14 +293,7 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { ON civicrm_mailing_job.mailing_id = {$this->_aliases['civicrm_mailing']}.id AND civicrm_mailing_job.is_test = 0 "; - - if ($this->_phoneField) { - $this->_from .= " - LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} - ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id - AND {$this->_aliases['civicrm_phone']}.is_primary = 1 - "; - } + $this->joinPhoneFromContact(); } public function where() { diff --git a/CRM/Report/Form/Mailing/Detail.php b/CRM/Report/Form/Mailing/Detail.php index f028d236ba..7a55a5c034 100644 --- a/CRM/Report/Form/Mailing/Detail.php +++ b/CRM/Report/Form/Mailing/Detail.php @@ -443,12 +443,7 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { ON civicrm_mailing_job.mailing_id = {$this->_aliases['civicrm_mailing']}.id AND civicrm_mailing_job.is_test = 0"; - if ($this->_phoneField) { - $this->_from .= " - LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} - ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id AND - {$this->_aliases['civicrm_phone']}.is_primary = 1 "; - } + $this->joinPhoneFromContact(); } public function where() { diff --git a/CRM/Report/Form/Mailing/Opened.php b/CRM/Report/Form/Mailing/Opened.php index 08ced58dbc..5a48f9e56f 100644 --- a/CRM/Report/Form/Mailing/Opened.php +++ b/CRM/Report/Form/Mailing/Opened.php @@ -279,14 +279,7 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { ON civicrm_mailing_job.mailing_id = {$this->_aliases['civicrm_mailing']}.id AND civicrm_mailing_job.is_test = 0 "; - - if ($this->_phoneField) { - $this->_from .= " - LEFT JOIN civicrm_phone {$this->_aliases['civicrm_phone']} - ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_phone']}.contact_id - AND {$this->_aliases['civicrm_phone']}.is_primary = 1 - "; - } + $this->joinPhoneFromContact(); } public function where() {