Skip to content

Commit

Permalink
Merge pull request #1612 from CartoDB/reorganize_do_columns
Browse files Browse the repository at this point in the history
Reorganize do columns
  • Loading branch information
Jesus89 authored Apr 3, 2020
2 parents a013e92 + 4d9ebb8 commit 0171f60
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 46 deletions.
20 changes: 10 additions & 10 deletions cartoframes/data/observatory/catalog/repository/dataset_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@ def _get_rows(self, filters=None):

def _map_row(self, row):
return {
'id': self._normalize_field(row, self.id_field),
'slug': self._normalize_field(row, 'slug'),
'name': self._normalize_field(row, 'name'),
'description': self._normalize_field(row, 'description'),
'category_id': self._normalize_field(row, 'category_id'),
'country_id': self._normalize_field(row, 'country_id'),
'geography_id': self._normalize_field(row, 'geography_id'),
'data_source_id': self._normalize_field(row, 'data_source_id'),
'provider_id': self._normalize_field(row, 'provider_id'),
'geography_name': self._normalize_field(row, 'geography_name'),
'geography_description': self._normalize_field(row, 'geography_description'),
'category_id': self._normalize_field(row, 'category_id'),
'category_name': self._normalize_field(row, 'category_name'),
'provider_id': self._normalize_field(row, 'provider_id'),
'provider_name': self._normalize_field(row, 'provider_name'),
'data_source_id': self._normalize_field(row, 'data_source_id'),
'lang': self._normalize_field(row, 'lang'),
'temporal_aggregation': self._normalize_field(row, 'temporal_aggregation'),
'time_coverage': self._normalize_field(row, 'time_coverage'),
'update_frequency': self._normalize_field(row, 'update_frequency'),
'version': self._normalize_field(row, 'version'),
'is_public_data': self._normalize_field(row, 'is_public_data'),
'summary_json': self._normalize_field(row, 'summary_json')
'lang': self._normalize_field(row, 'lang'),
'version': self._normalize_field(row, 'version'),
'category_name': self._normalize_field(row, 'category_name'),
'provider_name': self._normalize_field(row, 'provider_name'),
'summary_json': self._normalize_field(row, 'summary_json'),
'geography_id': self._normalize_field(row, 'geography_id'),
'id': self._normalize_field(row, self.id_field)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,20 @@ def _get_rows(self, filters=None):

def _map_row(self, row):
return {
'id': self._normalize_field(row, self.id_field),
'slug': self._normalize_field(row, 'slug'),
'name': self._normalize_field(row, 'name'),
'description': self._normalize_field(row, 'description'),
'country_id': self._normalize_field(row, 'country_id'),
'provider_id': self._normalize_field(row, 'provider_id'),
'provider_name': self._normalize_field(row, 'provider_name'),
'lang': self._normalize_field(row, 'lang'),
'geom_coverage': self._normalize_field(row, 'geom_coverage'),
'geom_type': self._normalize_field(row, 'geom_type'),
'geom_coverage': self._normalize_field(row, 'geom_coverage'),
'update_frequency': self._normalize_field(row, 'update_frequency'),
'version': self._normalize_field(row, 'version'),
'is_public_data': self._normalize_field(row, 'is_public_data'),
'summary_json': self._normalize_field(row, 'summary_json')
'lang': self._normalize_field(row, 'lang'),
'version': self._normalize_field(row, 'version'),
'provider_name': self._normalize_field(row, 'provider_name'),
'summary_json': self._normalize_field(row, 'summary_json'),
'id': self._normalize_field(row, self.id_field)
}

def get_geographies_gdf(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ def _map_row(self, row):
'id': self._normalize_field(row, self.id_field),
'slug': self._normalize_field(row, 'slug'),
'name': self._normalize_field(row, 'name'),
'dataset_id': self._normalize_field(row, 'dataset_id'),
'starred': self._normalize_field(row, 'starred')
'dataset_id': self._normalize_field(row, 'dataset_id')
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ def _get_rows(self, filters=None):

def _map_row(self, row):
return {
'id': self._normalize_field(row, self.id_field),
'slug': self._normalize_field(row, 'slug'),
'name': self._normalize_field(row, 'name'),
'description': self._normalize_field(row, 'description'),
'column_name': self._normalize_field(row, 'column_name'),
'db_type': self._normalize_field(row, 'db_type'),
'dataset_id': self._normalize_field(row, 'dataset_id'),
'agg_method': self._normalize_field(row, 'agg_method'),
'summary_json': self._normalize_field(row, 'summary_json'),
'column_name': self._normalize_field(row, 'column_name'),
'variable_group_id': self._normalize_field(row, 'variable_group_id'),
'starred': self._normalize_field(row, 'starred'),
'summary_json': self._normalize_field(row, 'summary_json')
'dataset_id': self._normalize_field(row, 'dataset_id'),
'id': self._normalize_field(row, self.id_field),
}


Expand Down
5 changes: 0 additions & 5 deletions cartoframes/data/observatory/catalog/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ def variable_group(self):
"""If any, ID of the variable group to which this variable belongs."""
return self.data['variable_group_id']

@property
def starred(self):
"""Boolean indicating whether this variable is a starred one or not. Internal usage only"""
return self.data['starred']

@property
def summary(self):
"""JSON object with extra metadata that summarizes different properties of this variable."""
Expand Down
5 changes: 0 additions & 5 deletions cartoframes/data/observatory/catalog/variable_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,3 @@ def name(self):
def dataset(self):
"""ID of the dataset related to this variable group."""
return self.data['dataset_id']

@property
def starred(self):
"""Boolean indicating whether this variable group is a starred one or not.."""
return self.data['starred']
8 changes: 2 additions & 6 deletions tests/unit/data/observatory/catalog/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
'dataset_id': 'dataset1',
'agg_method': '',
'variable_group_id': 'vargroup1',
'starred': True,
'summary_json': None
}
db_variable2 = {
Expand All @@ -148,7 +147,6 @@
'dataset_id': 'dataset1',
'agg_method': '',
'variable_group_id': 'vargroup1',
'starred': False,
'summary_json': [{'key': 'value'}]
}
test_variable1 = Variable(db_variable1)
Expand All @@ -171,15 +169,13 @@
'id': 'carto-do.variable_group.vargroup1',
'slug': 'vargroup1',
'name': 'Population',
'dataset_id': 'dataset1',
'starred': True
'dataset_id': 'dataset1'
}
db_variable_group2 = {
'id': 'carto-do.variable_group.vargroup2',
'slug': 'vargroup2',
'name': 'Date',
'dataset_id': 'dataset1',
'starred': False
'dataset_id': 'dataset1'
}
test_variable_group1 = VariableGroup(db_variable_group1)
test_variable_group2 = VariableGroup(db_variable_group2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ def test_missing_fields_are_mapped_as_None(self, mocked_repo):
'id': 'variable_group1',
'slug': None,
'name': None,
'dataset_id': None,
'starred': None
'dataset_id': None
})])

# When
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def test_missing_fields_are_mapped_as_None(self, mocked_repo):
'dataset_id': None,
'agg_method': None,
'variable_group_id': None,
'starred': None,
'summary_json': None
})])

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/data/observatory/catalog/test_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def test_variable_properties(self):
dataset = variable.dataset
agg_method = variable.agg_method
variable_group = variable.variable_group
starred = variable.starred
summary = variable.summary

# Then
Expand All @@ -66,7 +65,6 @@ def test_variable_properties(self):
assert dataset == db_variable1['dataset_id']
assert agg_method == db_variable1['agg_method']
assert variable_group == db_variable1['variable_group_id']
assert starred == db_variable1['starred']
assert summary == db_variable1['summary_json']

def test_variable_is_exported_as_series(self):
Expand Down
2 changes: 0 additions & 2 deletions tests/unit/data/observatory/catalog/test_variable_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,12 @@ def test_variable_group_properties(self):
slug = variable_group.slug
name = variable_group.name
dataset = variable_group.dataset
starred = variable_group.starred

# Then
assert variable_group_id == db_variable_group1['id']
assert slug == db_variable_group1['slug']
assert name == db_variable_group1['name']
assert dataset == db_variable_group1['dataset_id']
assert starred == db_variable_group1['starred']

def test_variable_group_is_exported_as_series(self):
# Given
Expand Down

0 comments on commit 0171f60

Please sign in to comment.