Skip to content

Commit ecb2908

Browse files
committed
add all agencies argument
1 parent e03d978 commit ecb2908

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

regcensus/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def get_values(series, jurisdiction, date, filtered=True, summary=True,
2424
summary (optional): Return summary instead of document level data
2525
filtered (optional): Exclude poorly-performing industry results
2626
documentType (optional): ID for type of document
27-
agency (optional): Agency ID
27+
agency (optional): Agency ID (use 'all' for all agencies,
28+
only works for a single jurisdiction)
2829
industry (optional): Industry code using the jurisdiction-specific
2930
coding system (use 'all' for all industries)
3031
dateIsRange (optional): Indicating whether the time parameter is range
@@ -65,6 +66,9 @@ def get_values(series, jurisdiction, date, filtered=True, summary=True,
6566
pp.pprint(list_jurisdictions())
6667
return
6768

69+
# Allows for all agency data to be returned
70+
if str(agency).lower() == 'all':
71+
agency = list(list_agencies(jurisdiction).values())
6872
# If multiple agencies are given, parses the list into a string
6973
if type(agency) == list:
7074
url_call += f'&agency={",".join(str(i) for i in agency)}'

tests/test_api.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ def test_get_values_agency():
150150
assert order_results(results, 'seriesValue') == [62.0]
151151

152152

153+
def test_get_values_all_agencies():
154+
results = rc.get_values(
155+
series=91, jurisdiction=38, date=2019, agency='all'
156+
)
157+
assert order_results(results, 'seriesValue') == [
158+
0.0, 0.0, 1.0, 1.0, 5.0, 18.0, 33.0, 34.0, 50.0, 59.0
159+
]
160+
161+
153162
def test_get_values_multiple_agencies():
154163
results = rc.get_values(
155164
series=91, jurisdiction=38, date=2019, agency=[111, 99]

0 commit comments

Comments
 (0)