CRM-21677 reduce unnecessary joins in mailing reports
authoryashodha <yashodha@cividesk.com>
Mon, 26 Mar 2018 06:44:49 +0000 (12:14 +0530)
committeryashodha <yashodha@cividesk.com>
Mon, 26 Mar 2018 06:44:49 +0000 (12:14 +0530)
CRM/Report/Form/Mailing/Bounce.php
CRM/Report/Form/Mailing/Clicks.php
CRM/Report/Form/Mailing/Detail.php
CRM/Report/Form/Mailing/Opened.php

index 574d1659f9c8957e58f2e3ddbe12e1c3955685bf..9d438b72a2818eb2d27852ce7b0ee19e6a47fd04 100644 (file)
@@ -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() {
index 31e6429226364e5a00f349251575a9bdc104c087..4bfa795ac8dad1d854716ee602940f2aa12091d9 100644 (file)
@@ -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() {
index f028d236bac7b394b0f747ce4d0cba50168fe0e3..7a55a5c034ff342a38a8e0e210228ebdd1e0875f 100644 (file)
@@ -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() {
index 08ced58dbc7a089c6c4bedf671419bd88e37268b..5a48f9e56fda765f7a1bda883447ff8993721028 100644 (file)
@@ -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() {