Skip to content

Commit

Permalink
Updates to count in a simpler way
Browse files Browse the repository at this point in the history
  • Loading branch information
jadudm committed Apr 3, 2024
1 parent 320671b commit dc209ea
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions count-march-submissions/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,39 @@ def string_to_datetime(strdate):
# aln_from_report_id : string -> list-of strings
# Given a report ID, returns all of the ALNs for associated federal awards
def count_submissions_in_march(year):
start_date = string_to_datetime(f"{year+1}-03-01")
end_date = string_to_datetime(f"{year+1}-03-31")
start_date = string_to_datetime(f"{year}-03-01")
end_date = string_to_datetime(f"{year}-03-31")
url = f"{FAC_API_BASE}/general"
params = {
"audit_year": f"eq.{year}",
"select": "report_id,audit_year,fac_accepted_date"
}
limit = 20_000
more = True
hist = {}
for off in range(0, 300_000, limit):
if more:
res = requests.get(url,
params=params | {"offset": off, "limit": limit-1},
headers={ "X-API-Key": FAC_API_KEY })
resjson = res.json()
if len(resjson) == 0:
more = False
else:
for r in resjson:
accepted = string_to_datetime(r["fac_accepted_date"])
for day in range(1, 31):
if (accepted == string_to_datetime(f"{year+1}-03-{str(day).zfill(2)}")):
hist[day] = hist.get(day, 0) + 1
for day in range (1, 32):
check = string_to_datetime(f"{year}-03-{str(day).zfill(2)}").strftime("%Y-%m-%d")
print(f"Running {check}...")
params = {
"fac_accepted_date": f"eq.{check}",
"select": "report_id,audit_year,fac_accepted_date"
}
res = requests.get(url,
params=params,
headers={ "X-API-Key": FAC_API_KEY })
resjson = res.json()
hist[day] = hist.get(day, 0) + len(resjson)
return hist

import sys

hists = {}
# for year in range(16, 24):
year=23
# This is the audit year. I add one for the acceptance date.

try:
int(sys.argv[1])
except:
print("You must supply a two-digit year.")
sys.exit(-1)

year=int(sys.argv[1])
print(f"Counting {2000+year}")
h = count_submissions_in_march(2000 + year)
print(h)
Expand Down

0 comments on commit dc209ea

Please sign in to comment.