Skip to content

Commit

Permalink
various: Updates for changes to the standard
Browse files Browse the repository at this point in the history
recipientOrganization is now optional so we need to not assume it
exists.
  • Loading branch information
michaelwood committed Dec 19, 2022
1 parent d9a9b0f commit 8d53b2c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions datastore/additional_data/sources/find_that_charity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def __init__(self, *args, **kwargs):
self._cache = {}

def update_additional_data(self, grant, additional_data):
# We can't do anything if this grant doesn't have a recipientOrganization
if not grant.get("recipientOrganization"):
return

if "id" not in grant["recipientOrganization"][0]:
return

Expand Down
4 changes: 4 additions & 0 deletions datastore/data_quality/quality_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def extract_org_id_type(org_id):
return None

for grant in grants["grants"]:
# skip if grant isn't for an organization
if not grant.get("recipientOrganization"):
continue

org_id_type = extract_org_id_type(grant["recipientOrganization"][0]["id"])
if org_id_type:
try:
Expand Down
2 changes: 1 addition & 1 deletion datastore/db/management/commands/manage_entities_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def update_entities():
print("Analysing latest best grant data for entities")

for grant in grants:
for recipient in grant["recipientOrganization"]:
for recipient in grant.get("recipientOrganization", []):
# If the org-id provided is a non-primary org-id return the primary
# otherwise return the specified org-id
org_id = non_primary_org_ids_map_cache.get(recipient["id"], recipient["id"])
Expand Down

0 comments on commit 8d53b2c

Please sign in to comment.