-
Notifications
You must be signed in to change notification settings - Fork 0
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
Given an IATI (activity) identifier, find the activity (efficiently!) #3
Comments
Obviously this sort of thing is already possible: for p in iatikit.publishers():
activity = p.activities.find(iati_identifier=activity_id)
if activity:
break This would be the way to do it inefficiently. I’m looking for the quick way! |
Done in d32bc52. |
So, this now works, and is quite fast: import iatikit
activity_id = 'GB-COH-07676886-999999'
try:
activity = iatikit.data().activities.find(iati_identifier=activity_id, fast=True)
print('success! Found activity with IATI identifier: "{}"'.format(activity_id))
except IndexError:
print('failed! Could not find an activity with IATI identifier: "{}"'.format(activity_id))
# failed! Could not find an activity with IATI identifier: "GB-COH-07676886-999999" |
Reopening because I removed this feature. It was experimental and had some problems. |
One of the problems here is: publishers can change their org ID, but they don’t declare this at org level (either in their org metadata or in their org file). So it’s non-trivial to do a fast lookup for activities that use old org IDs. |
Doing this efficiently means leaning on the rule that all activity IDs must be prefixed by the publisher’s org ID.
E.g.:
The text was updated successfully, but these errors were encountered: