josephlacey / com.jlacey.electoral

GNU Affero General Public License v3.0
6 stars 12 forks source link

Country districts stopped working after I increased limit #12

Closed d0325mgray closed 5 years ago

d0325mgray commented 5 years ago

I increased the limit from 100 to 1000 and it stopped working. I set it back down to 100 and it still fails

Parameters raw (from db settings): level=country limit=100 update=0

Parameters parsed (and passed to API method): 
a:4:{s:7:"version";i:3;s:5:"level";s:7:"country";s:5:"limit";s:3:"100";s:6:"update";s:1:"0";}

Full message: 
Finished execution of Google Civic Information API - Country Districts with result: Failure, Error message: 
d0325mgray commented 5 years ago

Mandatory key(s) missing from params array: entity_id

Sorry truncated it

d0325mgray commented 5 years ago

Eileen from Fuzion wrote this:

probably because you've hit a row that is problematic for some reason

so it wasn't the limit so much as that you brought that row into scope

jimcrist commented 5 years ago

That's the error I get immediately. I can't get this to work at all. It creates all the database structures but the civicrm_values_electoral_districts has 0 rows in it. I'm so frustrated!!! For more info see: https://github.com/josephlacey/com.jlacey.electoral/issues/7

d0325mgray commented 5 years ago

I have successfully processed over 1000 records

d0325mgray commented 5 years ago

I think I may have reached the daily limit, although Google says it is 25,000, not 2500

jimcrist commented 5 years ago

To be clear, I'm trying to add Wisconsin state districts: Google Civic Information API - State and Province Districts (Daily) Adds state and province districts to contacts via the Google Civic Information API API Entity: GoogleCivicInformation API Action: districts level=administrativeArea1 limit=100 update=0 Edit: What does 'update'=0 mean?

d0325mgray commented 5 years ago

I'm only interested in Congressional Districts for all states

d0325mgray commented 5 years ago

I uninstalled and reinstalled and still get the same error

d0325mgray commented 5 years ago

I had selected California only. I then removed that and chose Alaska. It ran successfully.

d0325mgray commented 5 years ago

At this point, I am not saying that increasing the limit had anything to do with the error. There is probably a contact record with some bad data that cannot get trapped.

jimcrist commented 5 years ago

I have 0 Alaska records. I have only 16 contacts from California, but I tried running California Congressional Districts and got the same error. Your early success implies it's data related.

josephlacey commented 5 years ago

Hey y'all,

As I told Jim on issue #7, the below error message isn't enough to know where the bug is.

Mandatory key(s) missing from params array: entity_id

The message seems to be related to an API call, but I'm using them all over the place, so I don't know which it is. Have y'all checked the CiviCRM log? It will likely have a backtrace with the line number in question that's throwing the error.

The additional information that this seems to be data related helps. I know event addresses are stored in the civicrm_address table without a contact_id, so if y'all have events in Civi, these might causing problems. I'm not certain this is the issue though.

I did run a lint test and found one bug, so I've pushed the fix. It does relate to the storing of errors when addresses don't return a result, which would be data related. Maybe patching this commit will help?

aa4fc199f853f49ddd78c87d60b3c7b52ca327b3

Edit: What does 'update'=0 mean?

update=0 means only add districts to addresses that don't currently have one associated with it. You could read this as, create new districts only, don't overwrite existing ones. The implementation is flawed here though because if you set this to 1, you'll likely only be ever redistricting the same 100, 1000, whatever your limit is.

Joseph

jimcrist commented 5 years ago

I took that 'es' out of api/v3/GoogleCivicInformation.php. Ran it and got a 100 of these: Not Configured. Google Civic Information API has not been used in project 917xxx before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/civicinfo.googleapis.com/overview?project=917xxx then retry. Fixed that, then it worked!!! Thank you so much Joseph!!!

d0325mgray commented 5 years ago

I haven't done a patch like this. Any help?

d0325mgray commented 5 years ago

I'll check the log in the morning. Getting late here.

josephlacey commented 5 years ago

@d0325mgray

I haven't done a patch like this. Any help?

In this case, it's very small, so you could edit the code directly and remove errant 'es'. The commit shows the file and line in the code that needs updating. Otherwise, you can redownload the whole extension and upload it on top of the current version (or however you deploy code), and that should apply the patch.

I'll check the log in the morning. Getting late here.

Jim's reporting that aa4fc199f853f49ddd78c87d60b3c7b52ca327b3 fixed the bug for him, so you might try that before digging around in the logs

d0325mgray commented 5 years ago

Thank you! That fixed it.

Country Districts with result: Success (99 addresses districted. 1 addresses with errors

Where do I find the address with errors? Is that logged somewhere?

josephlacey commented 5 years ago

Where do I find the address with errors? Is that logged somewhere?

Again, I suggest the Search Builder. I'd search for contacts where addresses a given type, whichever type is configured as the district address location, has a value in the custom field Error Code in the field set Electoral Status.

josephlacey commented 5 years ago

Fixed with aa4fc199f853f49ddd78c87d60b3c7b52ca327b3

d0325mgray commented 5 years ago

I found it with search builder