Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pupa identifiers #280

Merged
merged 6 commits into from May 25, 2017
Merged

pupa identifiers #280

merged 6 commits into from May 25, 2017

Conversation

fgregg
Copy link
Contributor

@fgregg fgregg commented May 23, 2017

This PR will add an ability to for the scraper to specify a pupa only identifier for vote events and events. Sometimes the scraper can know that two ocd objects are the same or different, even though the ocd attributes are not clear.

This will close #274.

I decided to take a GenericRelations approach. I think it's pretty reasonable.

@jamesturk @mileswwatkins , I'd like feedback on the general approach.

I'd also like thoughts on the name. I don't really like pupa_id but couldn't find a better name.

To do

  • tests for events

@coveralls
Copy link

coveralls commented May 23, 2017

Coverage Status

Coverage increased (+3.2%) to 94.783% when pulling f2774fa on datamade:identifier into 0a92a1a on opencivicdata:master.

@coveralls
Copy link

coveralls commented May 23, 2017

Coverage Status

Coverage increased (+3.2%) to 94.783% when pulling c4171e9 on datamade:identifier into 0a92a1a on opencivicdata:master.

@coveralls
Copy link

coveralls commented May 23, 2017

Coverage Status

Coverage increased (+3.5%) to 95.145% when pulling 58595b0 on datamade:identifier into 0a92a1a on opencivicdata:master.

@jamesturk
Copy link
Member

OK, took some time to think this through. I think it makes sense.

  • after waffling on if it should be here or in py-ocd, keeping it here does seem right
  • I'm good w/ the approach, the GenericForeignKey shouldn't incur much expense since this is only done at import time

I have a few implementation suggestions, I'll make those inline, but in general I think I'm a 👍

@jamesturk
Copy link
Member

jamesturk commented May 24, 2017

unrelated (except that we should ensure this patch matches) I noticed it had been a while since flake8 had been run on pupa, currently working on adding that to the travis job so we can stay consistent in the future & cleaning up the rough edges

@fgregg
Copy link
Contributor Author

fgregg commented May 24, 2017

cool. should we do flake8 cleanup as a separately from this PR?

@fgregg
Copy link
Contributor Author

fgregg commented May 24, 2017

okay, I rebased on your flake8 changes and brought my code into flake8 compliance.

@coveralls
Copy link

Coverage Status

Coverage increased (+3.5%) to 95.145% when pulling 02520dd on datamade:identifier into ebd7a6c on opencivicdata:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+3.5%) to 95.145% when pulling 02520dd on datamade:identifier into ebd7a6c on opencivicdata:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+3.5%) to 95.145% when pulling 02520dd on datamade:identifier into ebd7a6c on opencivicdata:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+3.5%) to 95.145% when pulling 02520dd on datamade:identifier into ebd7a6c on opencivicdata:master.

@fgregg fgregg changed the title [WIP] pupa identifiers pupa identifiers May 24, 2017
@coveralls
Copy link

coveralls commented May 25, 2017

Coverage Status

Coverage increased (+0.08%) to 95.148% when pulling 41cfd16 on datamade:identifier into 566758d on opencivicdata:master.

@fgregg
Copy link
Contributor Author

fgregg commented May 25, 2017

@jamesturk, bump

@jamesturk
Copy link
Member

ah thanks- any thoughts on the code tweaks? I'm glad to merge today then make them (or we can hold off on the #280 (diff) piece too if you think it doesn't make sense)

@fgregg
Copy link
Contributor Author

fgregg commented May 25, 2017

sorry, I don't see the tweaks?

Copy link
Member

@jamesturk jamesturk left a comment

Choose a reason for hiding this comment

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

oops, still not quite comfortable w/ the new review UI on here, I guess this was only visible to me

@@ -281,6 +284,14 @@ def import_item(self, data):
self.model_class))
self._create_related(obj, related, self.related_models)

if pupa_id:
Copy link
Member

Choose a reason for hiding this comment

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

might be more clear to use the built-in get_or_create

Identifier.objects.get_or_create(identifier=pupa_id, defaults={'content_object':obj})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cool, I didn't know about the defaults arg!

'timezone': event['timezone'],
'jurisdiction_id': self.jurisdiction_id
}
if event.get('pupa_id'):
Copy link
Member

Choose a reason for hiding this comment

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

do you think this snippet deserves a helper function? right now we're only using it in two places, but I'd imagine it'll be identical if/when it is added to any other pupa models

Copy link
Contributor Author

@fgregg fgregg May 25, 2017

Choose a reason for hiding this comment

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

Good idea! Where should things like that live?

@@ -40,7 +41,13 @@ def get_object(self, vote_event):
)
spec['bill_id'] = vote_event['bill_id']

if vote_event['identifier']:
if vote_event.get('pupa_id'):
Copy link
Member

Choose a reason for hiding this comment

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

see above

@jamesturk
Copy link
Member

jamesturk commented May 25, 2017 via email

@fgregg
Copy link
Contributor Author

fgregg commented May 25, 2017

okay, I think I've addressed your feedback. good points all!

@coveralls
Copy link

coveralls commented May 25, 2017

Coverage Status

Coverage increased (+0.07%) to 95.141% when pulling e59a662 on datamade:identifier into 566758d on opencivicdata:master.

@jamesturk jamesturk merged commit 16630a3 into opencivicdata:master May 25, 2017
@jamesturk
Copy link
Member

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Distinct vote events, despite same motion, org, and date
3 participants