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
pupa identifiers #280
Conversation
OK, took some time to think this through. I think it makes sense.
I have a few implementation suggestions, I'll make those inline, but in general I think I'm a 👍 |
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 |
cool. should we do flake8 cleanup as a separately from this PR? |
okay, I rebased on your flake8 changes and brought my code into flake8 compliance. |
3 similar comments
@jamesturk, bump |
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) |
sorry, I don't see the tweaks? |
There was a problem hiding this 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: |
There was a problem hiding this comment.
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})
There was a problem hiding this comment.
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'): |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above
hm, maybe just in the parent class?
…On Thu, May 25, 2017 at 10:13 AM, Forest Gregg ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pupa/importers/events.py
<#280 (comment)>:
> @@ -38,14 +39,21 @@ def __init__(self, jurisdiction_id, org_importer, person_importer, bill_importer
self.vote_event_importer = vote_event_importer
def get_object(self, event):
- spec = {
- 'name': event['name'],
- 'description': event['description'],
- 'start_time': event['start_time'],
- 'end_time': event['end_time'],
- 'timezone': event['timezone'],
- 'jurisdiction_id': self.jurisdiction_id
- }
+ if event.get('pupa_id'):
Good idea? Where should things like that live?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#280 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAfYgwbla3P0vip-Z1GH_lRQHxduMe5ks5r9ba3gaJpZM4NjEey>
.
|
okay, I think I've addressed your feedback. good points all! |
👍 |
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