Skip to content

Commit 89ea4ff

Browse files
committed
Added option for aggregate data for countries
1 parent 48d4ac7 commit 89ea4ff

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

app/routes/v2/latest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
from flask import jsonify
1+
from flask import jsonify, request
22
from ...routes import api_v2 as api
33
from ...services import jhu
44

55
@api.route('/latest')
66
def latest():
7+
#Query parameters.
8+
country_code = request.args.get('country_code', type=str)
9+
710
# Get the serialized version of all the locations.
811
locations = [ location.serialize() for location in jhu.get_all() ]
912

13+
# Return aggregate data for country if provided.
14+
if not country_code is None:
15+
locations = list(filter(lambda location: location['country_code'] == country_code.upper(), locations))
16+
1017
# All the latest information.
1118
latest = list(map(lambda location: location['latest'], locations))
1219

0 commit comments

Comments
 (0)