Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update country and lang column names in views #1073

Merged
merged 1 commit into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cartoframes/data/observatory/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ def data_source(self):

@property
def country(self):
return self.data['country_iso_code3']
return self.data['country_id']

@property
def language(self):
return self.data['language_iso_code3']
return self.data['lang']

@property
def geography(self):
Expand Down
4 changes: 2 additions & 2 deletions cartoframes/data/observatory/geography.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ def description(self):

@property
def country(self):
return self.data['country_iso_code3']
return self.data['country_id']

@property
def language(self):
return self.data['language_iso_code3']
return self.data['lang']

@property
def provider(self):
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/data/observatory/repository/country_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .entity_repo import EntityRepository


_COUNTRY_ID_FIELD = 'country_iso_code3'
_COUNTRY_ID_FIELD = 'country_id'


def get_country_repo():
Expand Down
6 changes: 3 additions & 3 deletions cartoframes/data/observatory/repository/dataset_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class DatasetRepository(EntityRepository):
id_field = _DATASET_ID_FIELD

def get_by_country(self, iso_code3):
return self._get_filtered_entities('country_iso_code3', iso_code3)
return self._get_filtered_entities('country_id', iso_code3)

def get_by_category(self, category_id):
return self._get_filtered_entities('category_id', category_id)
Expand All @@ -38,8 +38,8 @@ def _map_row(cls, row):
'provider_id': cls._normalize_field(row, 'provider_id'),
'category_id': cls._normalize_field(row, 'category_id'),
'data_source_id': cls._normalize_field(row, 'data_source_id'),
'country_iso_code3': cls._normalize_field(row, 'country_iso_code3'),
'language_iso_code3': cls._normalize_field(row, 'language_iso_code3'),
'country_id': cls._normalize_field(row, 'country_id'),
'lang': cls._normalize_field(row, 'lang'),
'geography_id': cls._normalize_field(row, 'geography_id'),
'temporal_aggregation': cls._normalize_field(row, 'temporal_aggregation'),
'time_coverage': cls._normalize_field(row, 'time_coverage'),
Expand Down
6 changes: 3 additions & 3 deletions cartoframes/data/observatory/repository/geography_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GeographyRepository(EntityRepository):
id_field = _GEOGRAPHY_ID_FIELD

def get_by_country(self, iso_code3):
return self._get_filtered_entities('country_iso_code3', iso_code3)
return self._get_filtered_entities('country_id', iso_code3)

@classmethod
def _map_row(cls, row):
Expand All @@ -24,8 +24,8 @@ def _map_row(cls, row):
'name': cls._normalize_field(row, 'name'),
'description': cls._normalize_field(row, 'description'),
'provider_id': cls._normalize_field(row, 'provider_id'),
'country_iso_code3': cls._normalize_field(row, 'country_iso_code3'),
'language_iso_code3': cls._normalize_field(row, 'language_iso_code3'),
'country_id': cls._normalize_field(row, 'country_id'),
'lang': cls._normalize_field(row, 'lang'),
'geom_coverage': cls._normalize_field(row, 'geom_coverage'),
'update_frequency': cls._normalize_field(row, 'update_frequency'),
'version': cls._normalize_field(row, 'version'),
Expand Down
2 changes: 1 addition & 1 deletion cartoframes/data/observatory/repository/repo_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self):
self.client = SQLClient(Credentials('do-metadata', 'default_public'))

def get_countries(self, field=None, value=None):
query = 'select distinct country_iso_code3 as id from datasets_public'
query = 'select distinct country_id as id from datasets_public'
return self._run_query(query, field, value)

def get_categories(self, field=None, value=None):
Expand Down
16 changes: 8 additions & 8 deletions test/data/observatory/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
'name': 'ESP - Census',
'description': 'Geography data for Spanish census',
'provider_id': 'bbva',
'country_iso_code3': 'esp',
'language_iso_code3': 'esp',
'country_id': 'esp',
'lang': 'esp',
'geom_coverage': '',
'update_frequency': 'monthly',
'version': '20190203',
Expand All @@ -43,8 +43,8 @@
'name': 'ESP - Municipalities',
'description': 'Geography data for Spanish municipalities',
'provider_id': 'bbva',
'country_iso_code3': 'esp',
'language_iso_code3': 'esp',
'country_id': 'esp',
'lang': 'esp',
'geom_coverage': '',
'update_frequency': 'monthly',
'version': '20190203',
Expand All @@ -62,8 +62,8 @@
'provider_id': 'bbva',
'category_id': 'demographics',
'data_source_id': 'basicstats',
'country_iso_code3': 'esp',
'language_iso_code3': 'esp',
'country_id': 'esp',
'lang': 'esp',
'geography_id': 'carto-do-public-data.tiger.geography_esp_census_2019',
'temporal_aggregation': '5yrs',
'time_coverage': ['2006-01-01', '2010-01-01'],
Expand All @@ -79,8 +79,8 @@
'provider_id': 'bbva',
'category_id': 'demographics',
'data_source_id': 'basicstats',
'country_iso_code3': 'esp',
'language_iso_code3': 'esp',
'country_id': 'esp',
'lang': 'esp',
'geography_id': 'carto-do-public-data.tiger.geography_esp_municipalities_2019',
'temporal_aggregation': '5yrs',
'time_coverage': ['2006-01-01', '2010-01-01'],
Expand Down
2 changes: 1 addition & 1 deletion test/data/observatory/repository/test_country_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_get_by_id(self, mocked_repo):
country = repo.get_by_id(requested_iso_code)

# Then
mocked_repo.assert_called_once_with('country_iso_code3', requested_iso_code)
mocked_repo.assert_called_once_with('country_id', requested_iso_code)
assert isinstance(country, Country)
assert country == test_country1

Expand Down
6 changes: 3 additions & 3 deletions test/data/observatory/repository/test_dataset_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_get_by_country(self, mocked_repo):
datasets = repo.get_by_country(country_code)

# Then
mocked_repo.assert_called_once_with('country_iso_code3', country_code)
mocked_repo.assert_called_once_with('country_id', country_code)
assert isinstance(datasets, CatalogList)
assert datasets == test_datasets

Expand Down Expand Up @@ -141,8 +141,8 @@ def test_missing_fields_are_mapped_as_None(self, mocked_repo):
'provider_id': None,
'category_id': None,
'data_source_id': None,
'country_iso_code3': None,
'language_iso_code3': None,
'country_id': None,
'lang': None,
'geography_id': None,
'temporal_aggregation': None,
'time_coverage': None,
Expand Down
6 changes: 3 additions & 3 deletions test/data/observatory/repository/test_geography_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_get_by_country(self, mocked_repo):
geographies = repo.get_by_country(country_code)

# Then
mocked_repo.assert_called_once_with('country_iso_code3', country_code)
mocked_repo.assert_called_once_with('country_id', country_code)
assert isinstance(geographies, CatalogList)
assert geographies == test_geographies

Expand All @@ -94,8 +94,8 @@ def test_missing_fields_are_mapped_as_None(self, mocked_repo):
'name': None,
'description': None,
'provider_id': None,
'country_iso_code3': None,
'language_iso_code3': None,
'country_id': None,
'lang': None,
'geom_coverage': None,
'update_frequency': None,
'version': None,
Expand Down
4 changes: 2 additions & 2 deletions test/data/observatory/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ def test_dataset_properties(self):
assert provider == db_dataset1['provider_id']
assert category == db_dataset1['category_id']
assert data_source == db_dataset1['data_source_id']
assert country == db_dataset1['country_iso_code3']
assert language == db_dataset1['language_iso_code3']
assert country == db_dataset1['country_id']
assert language == db_dataset1['lang']
assert geography == db_dataset1['geography_id']
assert temporal_aggregation == db_dataset1['temporal_aggregation']
assert time_coverage == db_dataset1['time_coverage']
Expand Down
4 changes: 2 additions & 2 deletions test/data/observatory/test_geography.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def test_geography_properties(self):
assert geography_id == db_geography1['id']
assert name == db_geography1['name']
assert description == db_geography1['description']
assert country == db_geography1['country_iso_code3']
assert language == db_geography1['language_iso_code3']
assert country == db_geography1['country_id']
assert language == db_geography1['lang']
assert provider == db_geography1['provider_id']
assert geom_coverage == db_geography1['geom_coverage']
assert update_frequency == db_geography1['update_frequency']
Expand Down