Skip to content

Commit 09e02b5

Browse files
committed
Fix continent codes form a set. Not a list
1 parent a6094ff commit 09e02b5

File tree

13 files changed

+359
-357
lines changed

13 files changed

+359
-357
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ __Sample response__
129129
"id": 39,
130130
"country": "Norway",
131131
"country_code": "NO",
132-
"continent_codes_list": ["EUR"],
132+
"continent_codes_set": {"EUR"},
133133
"country_population": 5009150,
134134
"province": "",
135135
"county": "",
@@ -176,7 +176,7 @@ __Sample response__
176176
"id": 0,
177177
"country": "Thailand",
178178
"country_code": "TH",
179-
"continent_codes_list": ["ASI"],
179+
"continent_codes_set": {"ASI"},
180180
"country_population": 67089500,
181181
"province": "",
182182
"county": "",
@@ -194,7 +194,7 @@ __Sample response__
194194
{
195195
"id": 39,
196196
"country": "Norway",
197-
"continent_codes_list": ["EUR"],
197+
"continent_codes_set": {"EUR"},
198198
"country_code": "NO",
199199
"province": "",
200200
"county": "",
@@ -227,8 +227,9 @@ __Response definitions__
227227
| {locations}/{location}/{latest}/deaths | The up-to-date number of deaths related to the specific location | Integer |
228228
| {locations}/{location}/{latest}/recovered | The up-to-date number of recovered related to the specific location | Integer |
229229
| {locations}/{location}/id | The location id. This unique id is assigned to the location by the data-source. | Integer |
230-
| {locations}/{location}/country | The Country name | String |
231-
| {locations}/{location}/country_code | The [ISO alpha-2 country_code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) Country code for the location. | String |
230+
| {locations}/{location}/country | The country name | String |
231+
| {locations}/{location}/country_code | The [ISO alpha-2 country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the country. | String |
232+
| {locations}/{location}/continent_codes_set | The List, in fact a set of alpha-3 continent codes of the country location. | List |
232233
| {locations}/{location}/province | The province where the location belongs to. (Used for US locations coming from __csbs data-source__.<br>__Empty__ when *jhu data-source* is used | String |
233234
| {locations}/{location}/{coordinates}/latitude | The location latitude | Float |
234235
| {locations}/{location}/{coordinates}/longitude | The location longitude | Float |
@@ -257,7 +258,7 @@ __Sample Response__
257258
"id": 16,
258259
"country": "Italy",
259260
"country_code": "IT",
260-
"continent_codes_list": ["EUR"],
261+
"continent_codes_set": {"EUR"},
261262
"country_population": 60340328,
262263
"province": "",
263264
"county": "",
@@ -298,7 +299,7 @@ __Sample Response__
298299
"id": 0,
299300
"country": "US",
300301
"country_code": "US",
301-
"continent_codes_list": ["NAC"],
302+
"continent_codes_set": {"NAC"},
302303
"country_population": 310232863,
303304
"province": "New York",
304305
"state": "New York",
@@ -318,7 +319,7 @@ __Sample Response__
318319
"id": 1,
319320
"country": "US",
320321
"country_code": "US",
321-
"continent_codes_list": ["NAC"],
322+
"continent_codes_set": {"NAC"},
322323
"country_population": 310232863,
323324
"province": "New York",
324325
"state": "New York",

app/location/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def country_code(self):
3434
return countries.country_code(self.country) or countries.default_country_code
3535

3636
@property
37-
def continent_codes_list(self):
37+
def continent_codes_set(self):
3838
"""
3939
Gets the alpha-3 code representations of the continent codes where the
4040
country represented by the country code is located. Returns 'CCC' if
@@ -44,7 +44,7 @@ def continent_codes_list(self):
4444
:rtype: list
4545
"""
4646
country_code = countries.country_code(self.country)
47-
return continents.continent_codes_list(country_code) or continents.default_continent_codes_list
47+
return continents.continent_codes_set(country_code) or continents.default_continent_codes_set
4848

4949
@property
5050
def country_population(self):
@@ -68,7 +68,7 @@ def serialize(self):
6868
"id": self.id,
6969
"country": self.country,
7070
"country_code": self.country_code,
71-
"continent_codes_list": self.continent_codes_list,
71+
"continent_codes_set": self.continent_codes_set,
7272
"country_population": self.country_population,
7373
"province": self.province,
7474
# Coordinates.

app/models/location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Location(BaseModel):
1414
id: int
1515
country: str
1616
country_code: str
17-
continent_codes_list: list = []
17+
continent_codes_set: set = {}
1818
country_population: int = None
1919
province: str = ""
2020
county: str = ""

app/router/v2/locations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def get_locations(
1111
request: Request,
1212
source: Sources = "jhu",
1313
country_code: str = None,
14-
continent_codes_list: list = [],
14+
continent_codes_set: list = {},
1515
province: str = None,
1616
county: str = None,
1717
timelines: bool = False,

app/services/location/jhu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def get_category(category):
8383
# General info.
8484
"country": country,
8585
"country_code": country_code,
86-
"continent_codes_list": continents.continent_codes_list(country_code),
86+
"continent_codes_set": list(continents.continent_codes_set(country_code)),
8787
"province": item["Province/State"],
8888
# Coordinates.
8989
"coordinates": {"lat": item["Lat"], "long": item["Long"],},

0 commit comments

Comments
 (0)