Skip to content

Commit

Permalink
refactor(Attributes): tile cache type is no longer needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtempus committed Jan 18, 2024
1 parent f2b4d76 commit 563b71a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/crud/async_db/vector_tiles/nasa_viirs_fire_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def get_aggregated_tile(
"""

columns: List[ColumnClause] = list()
attributes: List[str] = await get_attributes(SCHEMA, version, None)
attributes: List[str] = await get_attributes(SCHEMA, version)
for attribute in attributes:
columns.append(db.column(attribute))

Expand Down
2 changes: 1 addition & 1 deletion app/crud/sync_db/tile_cache_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def get_latest_versions() -> List[Dict[str, str]]:
return latest_versions


async def get_attributes(dataset, version, asset_type):
async def get_attributes(dataset, version):
# TODO: fetch the correct one for the current implementation
# needs changes to data-api to assure dynamic vector tile caches
# also have the implementation parameter in the creation options
Expand Down
5 changes: 1 addition & 4 deletions app/routes/dynamic_vector_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from ..crud.async_db.vector_tiles.filters import geometry_filter
from ..crud.sync_db.tile_cache_assets import get_attributes
from ..models.enumerators.geostore import GeostoreOrigin
from ..models.enumerators.tile_caches import TileCacheType
from ..models.types import Bounds
from ..responses import VectorTileResponse
from . import dynamic_vector_tile_cache_version_dependency, vector_xyz
Expand Down Expand Up @@ -61,9 +60,7 @@ async def dynamic_vector_tile(
if geom_filter is not None:
filters.append(geom_filter)

attributes: List[str] = await get_attributes(
dataset, version, TileCacheType.dynamic_vector_tile_cache
)
attributes: List[str] = await get_attributes(dataset, version)

# if no attributes specified get all feature info fields
if not include_attribute:
Expand Down
12 changes: 3 additions & 9 deletions tests/crud/sync_db/test_vector_tile_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ def test_get_static_fields():
"is_filter": False,
}
]
assert result == get_attributes(
"wdpa_protected_areas", "v201912", TileCacheType.static_vector_tile_cache
)
assert result == get_attributes("wdpa_protected_areas", "v201912")


@pytest.mark.xfail(
Expand All @@ -92,19 +90,15 @@ def test_get_dynamic_fields():
"is_filter": False,
}
]
assert result == get_attributes(
"nasa_viirs_fire_alerts", "v202003", TileCacheType.dynamic_vector_tile_cache
)
assert result == get_attributes("nasa_viirs_fire_alerts", "v202003")


@pytest.mark.xfail(
reason="The new implementation uses Data API not the DB. There is some refactoring to do before replacing these tests with valuable ones."
)
def test_get_non_existing_fields():
result = []
assert result == get_attributes(
"fails", "v2", TileCacheType.static_vector_tile_cache
)
assert result == get_attributes("fails", "v2")


def test_latest_date():
Expand Down

0 comments on commit 563b71a

Please sign in to comment.