Skip to content

Commit e8e50e8

Browse files
committed
add Totals
1 parent 1cfdc2c commit e8e50e8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

app/main.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Country(pydantic.BaseModel):
5151

5252

5353
class AllLocations(pydantic.BaseModel):
54-
latest: Totals = None # FIXME
54+
latest: Totals
5555
locations: List[Country]
5656

5757

@@ -139,11 +139,14 @@ def get_all_locations(
139139
locations,
140140
)
141141
)
142-
response_dict = {
143-
"locations": [location.serialize(timelines) for location in locations]
142+
return {
143+
"latest": {
144+
"confirmed": sum(map(lambda location: location.confirmed, locations)),
145+
"deaths": sum(map(lambda location: location.deaths, locations)),
146+
"recovered": sum(map(lambda location: location.recovered, locations)),
147+
},
148+
"locations": [location.serialize(timelines) for location in locations],
144149
}
145-
LOGGER.info(f"response: {reprlib.repr(response_dict)}")
146-
return response_dict
147150

148151

149152
@APP.get("/locations/{id}", response_model=Location)

0 commit comments

Comments
 (0)