Skip to content

Commit

Permalink
Modified functions in BatchUpdate.php file
Browse files Browse the repository at this point in the history
  • Loading branch information
pipeline authored and monishdeb committed Nov 1, 2023
1 parent 134a8dc commit 60ca79c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CRM/Core/BAO/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -1297,6 +1297,8 @@ public static function addGeocoderData(&$params) {
// ensure that if the geocoding provider (Google, OSM etc) has returned the string 'null' because they can't geocode, ensure that contacts are not placed on null island 0,0
if ($params[$geocode] !== 'null') {
$params[$geocode] = (float) substr($params[$geocode], 0, 14);
//set manual_geo_code to 0
$params['manual_geo_code'] = false;
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion CRM/Utils/Address/BatchUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ public function processContacts($processGeocode, $parseStreetAddress) {
if ($processGeocode) {
$clause[] = '( a.geo_code_1 is null OR a.geo_code_1 = 0 )';
$clause[] = '( a.geo_code_2 is null OR a.geo_code_2 = 0 )';
/**
* the scheduled job is ignoring trying to geocode addresses where manual_geocode is 1
*/
$clause[] = '( a.manual_geo_code = 0 )';
$clause[] = '( a.country_id is not null )';
}

Expand Down Expand Up @@ -164,6 +168,7 @@ public function processContacts($processGeocode, $parseStreetAddress) {
$dao = CRM_Core_DAO::executeQuery($query, $params);

$unparseableContactAddress = [];

while ($dao->fetch()) {
$totalAddresses++;
$params = [
Expand Down Expand Up @@ -211,6 +216,12 @@ public function processContacts($processGeocode, $parseStreetAddress) {
$totalGeocoded++;
$addressParams = $params;
}
else {
// If an address has failed in the geocoding scheduled job i.e. no lat/long is fetched, we will update the manual_geocode field to 1.
$addressParams['manual_geo_code'] = TRUE;
$addressParams['geo_code_1'] = 0;
$addressParams['geo_code_2'] = 0;
}
}

// parse street address
Expand All @@ -222,7 +233,6 @@ public function processContacts($processGeocode, $parseStreetAddress) {
if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
$success = FALSE;
}

// do check for all elements.
if ($success) {
$totalAddressParsed++;
Expand Down

0 comments on commit 60ca79c

Please sign in to comment.