Skip to content

Commit 0fffcf1

Browse files
committed
lib360dataquality: cove: Add aggregate award year information
This provides a summary of the number of grants with award years in each mentioned year in the dataset. This is to be used for the registry dashboard
1 parent 4c807cc commit 0fffcf1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib360dataquality/cove/threesixtygiving.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def get_grants_aggregates(json_data):
106106
duplicate_ids = set()
107107
max_award_date = ""
108108
min_award_date = ""
109+
award_years = {}
109110
distinct_funding_org_identifier = set()
110111
distinct_recipient_org_identifier = set()
111112
currencies = {}
@@ -139,6 +140,12 @@ def get_grants_aggregates(json_data):
139140

140141
award_date = str(grant.get("awardDate", ""))
141142
if award_date:
143+
try:
144+
year = award_date[:4]
145+
# count up the tally of grants in `year`
146+
award_years[year] = award_years[year] + 1
147+
except KeyError:
148+
award_years[year] = 1
142149
max_award_date = max(award_date, max_award_date)
143150
if not min_award_date:
144151
min_award_date = award_date
@@ -182,6 +189,7 @@ def get_grants_aggregates(json_data):
182189
"duplicate_ids": duplicate_ids,
183190
"max_award_date": max_award_date.split("T")[0],
184191
"min_award_date": min_award_date.split("T")[0],
192+
"award_years": award_years,
185193
"distinct_funding_org_identifier": distinct_funding_org_identifier,
186194
"distinct_recipient_org_identifier": distinct_recipient_org_identifier,
187195
"currencies": currencies,

0 commit comments

Comments
 (0)