Action Network: add more useful functions#74
Conversation
…ople_dataframe, paginate_endpoint, and fetch_related_people
scwikla
left a comment
There was a problem hiding this comment.
going to look at this more closely today. off the bat, we will need to add tests in addition to any code changes. stac-utils a little harder core
Added some really basic unit tests for core functionality, for each function. Let me know if you want more coverage here |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #74 +/- ##
==========================================
+ Coverage 95.48% 95.67% +0.19%
==========================================
Files 25 25
Lines 1062 1109 +47
Branches 122 131 +9
==========================================
+ Hits 1014 1061 +47
Misses 36 36
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
if it's alright, would you mind looking @DarrFranco ? just because these are utils would like better engineering eyes in case i don't see something |
| return pd.DataFrame(rows) | ||
|
|
||
| def paginate_endpoint( | ||
| self, base_endpoint: str, embedded_key: str, max_pages: int = None, **kwargs |
There was a problem hiding this comment.
I think if we know payloads/responses are consistent these look fine
There was a problem hiding this comment.
They should be. Person fields from: https://actionnetwork.org/docs/v2/people/
| full_endpoint = f"{base_endpoint}?page={page}" | ||
| data = self.get(full_endpoint, **kwargs) | ||
|
|
||
| embedded = data.get("_embedded", {}) |
There was a problem hiding this comment.
same for this, I think if we always have these specific things we look for (ie: '_embedded") it should be fine
There was a problem hiding this comment.
For all endpoints that return some sort of collection of items (forms, submissions, events, etc), they should always have a "_embedded" field, from what I can see from the documentation: https://actionnetwork.org/docs/v2
scwikla
left a comment
There was a problem hiding this comment.
ok see the dennis comments have been addressed - will approve but let engineering merge @KeshSridhar
Checklist for this pull request:
Description:
Adding reusable functions for the Action Network API. Functions include:
extract_action_network_id: parses through a person record's Action Network identifiers and grabs just the Action Network ID
create_people_dataframe: Returns a pandas dataframe given an iterable of Action Network people from the Action Network people API endpoint
paginate_endpoint: Pagination helper for Action Network API endpoints
fetch_related_people: Given a resource dict (i.e. a submission or signup), fetches all related people records