Skip to content

Modified functions in BatchUpdate.php file#139

Open
Edzelopez wants to merge 1 commit into
masterfrom
improve-geocoding-for-address
Open

Modified functions in BatchUpdate.php file#139
Edzelopez wants to merge 1 commit into
masterfrom
improve-geocoding-for-address

Conversation

@Edzelopez
Copy link
Copy Markdown
Member

Overview

A brief description of the pull request. Keep technical jargon to a minimum. Hyperlink relevant discussions.

Before

What is the old user-interface or technical-contract (as appropriate)?
For optimal clarity, include a concrete example such as a screenshot, GIF (LICEcap, SilentCast), or code-snippet.

After

What changed? What is new old user-interface or technical-contract?
For optimal clarity, include a concrete example such as a screenshot, GIF (LICEcap, SilentCast), or code-snippet.

Technical Details

If the PR involves technical details/changes/considerations which would not be manifest to a casual developer skimming the above sections, please describe the details here.

Comments

Anything else you would like the reviewer to note

Comment thread CRM/Utils/Address/BatchUpdate.php Outdated
$unparseableContactAddress[] = " Contact ID: " . $dao->id . " <a href =\"$url\"> " . $dao->street_address . " </a> ";
// reset element values.
$parsedFields = array_fill_keys(array_keys($parsedFields), '');
/**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines should be moved to L219 in an else code block. This is because this part of the code is about street addressing parsing not geocoding

Comment thread CRM/Utils/Address/BatchUpdate.php Outdated
* 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.
*/
$results = \Civi\Api4\Address::update()
->addValue('manual_geo_code', true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also this should be changed I think to be like

$addressParams = [
  'manual_geo_code' => 1,
  'geo_code_1' => 0,
  'geo_code_2' => 1,
 ];

Comment thread CRM/Utils/Address/BatchUpdate.php Outdated
// when we should found street_number and street_name
if (empty($parsedFields['street_name']) || empty($parsedFields['street_number'])) {
$success = FALSE;
// 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.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maryguo2023 these 4 lines need to be moved in Old line 214

Copy link
Copy Markdown
Member

@seamuslee001 seamuslee001 Oct 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code there should be like the following as this section is about address parsing not geocoding of addresses

        if (isset($params['geo_code_1']) && $params['geo_code_1'] != 'null') {
          $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;
        }

@monishdeb monishdeb force-pushed the improve-geocoding-for-address branch from f19459f to bb6526c Compare November 1, 2023 11:00
@monishdeb monishdeb force-pushed the improve-geocoding-for-address branch 3 times, most recently from 60ca79c to 8ea205e Compare November 1, 2023 11:39
@monishdeb monishdeb force-pushed the improve-geocoding-for-address branch from 8ea205e to 30027f9 Compare November 1, 2023 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants