From: Monish Deb Date: Mon, 24 Aug 2020 12:18:25 +0000 (+0530) Subject: Optimise proximity custom search, by reducing addGeocodingData fn call X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=637368b5efbb8aa007a8fa35b514421371bc2c5c;p=civicrm-core.git Optimise proximity custom search, by reducing addGeocodingData fn call --- diff --git a/CRM/Contact/Form/Search/Custom/Proximity.php b/CRM/Contact/Form/Search/Custom/Proximity.php index 34026c06de..8d211aafcf 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -19,9 +19,6 @@ */ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface { - protected $_latitude = NULL; - protected $_longitude = NULL; - protected $_distance = NULL; protected $_aclFrom = NULL; protected $_aclWhere = NULL; @@ -39,21 +36,6 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C unset($this->_formValues['uf_group_id']); unset($this->_formValues['component_mode']); unset($this->_formValues['operator']); - - if (!empty($this->_formValues)) { - // add the country and state - self::addGeocodingData($this->_formValues); - $this->_latitude = $this->_formValues['geo_code_1']; - $this->_longitude = $this->_formValues['geo_code_2']; - - if ($this->_formValues['prox_distance_unit'] == "miles") { - $conversionFactor = 1609.344; - } - else { - $conversionFactor = 1000; - } - $this->_distance = $this->_formValues['distance'] * $conversionFactor; - } $this->_group = $this->_formValues['group'] ?? NULL; $this->_tag = $this->_formValues['tag'] ?? NULL; @@ -192,6 +174,10 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C $isCountOnly = TRUE; } + if (empty($this->_formValues['geo_code_1']) || empty($this->_formValues['geo_code_2'])) { + self::addGeocodingData($this->_formValues); + } + $searchParams = [ ['prox_distance_unit', '=', $this->_formValues['prox_distance_unit'], 0, 0], ['prox_distance', '=', $this->_formValues['distance'], 0, 0],