33
44from fastapi import APIRouter , HTTPException , Request
55
6- from ..data import DATA_SOURCES
76from ..models import LatestResponse , LocationResponse , LocationsResponse
87
98V2 = APIRouter ()
@@ -26,7 +25,7 @@ async def get_latest(
2625 """
2726 Getting latest amount of total confirmed cases, deaths, and recoveries.
2827 """
29- locations = await request .state .source .get_all ()
28+ locations = await request .state .source .get_service (). get_all ()
3029 return {
3130 "latest" : {
3231 "confirmed" : sum (map (lambda location : location .confirmed , locations )),
@@ -57,7 +56,7 @@ async def get_locations(
5756 params .pop ("timelines" , None )
5857
5958 # Retrieve all the locations.
60- locations = await request .state .source .get_all ()
59+ locations = await request .state .source .get_service (). get_all ()
6160
6261 # Attempt to filter out locations with properties matching the provided query params.
6362 for key , value in params .items ():
@@ -98,7 +97,7 @@ async def get_location_by_id(
9897 """
9998 Getting specific location by id.
10099 """
101- location = await request .state .source .get (id )
100+ location = await request .state .source .get_service (). get (id )
102101 return {"location" : location .serialize (timelines )}
103102
104103
@@ -107,4 +106,4 @@ async def sources():
107106 """
108107 Retrieves a list of data-sources that are availble to use.
109108 """
110- return {"sources" : list ( DATA_SOURCES . keys ()) }
109+ return {"sources" : [ source . value for source in Sources ] }
0 commit comments