Skip to content

Commit

Permalink
linestrings -> lines
Browse files Browse the repository at this point in the history
  • Loading branch information
CannonLock committed May 11, 2024
1 parent ea3ef05 commit a8ada79
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions api/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def to_dict(self):
async def get_table(
conn,
table_id: int,
geometry_type: Literal["polygons", "points", "linestrings"]
geometry_type: Literal["polygons", "points", "lines"]
) -> Table:
metadata = MetaData(schema="sources")
table_slug = await source_id_to_slug(engine, table_id)
Expand All @@ -182,7 +182,7 @@ async def get_table(
async def get_sources_sub_table_count(
engine: AsyncEngine,
table_id: int,
geometry_type: Literal["polygons", "points", "linestrings"],
geometry_type: Literal["polygons", "points", "lines"],
query_params: list = None
) -> int:
async with engine.begin() as conn:
Expand Down Expand Up @@ -221,7 +221,7 @@ async def get_sources_sub_table_count(
async def select_sources_sub_table(
engine: AsyncEngine,
table_id: int,
geometry_type: Literal["polygons", "points", "linestrings"],
geometry_type: Literal["polygons", "points", "lines"],
page: int = 0,
page_size: int = 100,
query_params: list = None,
Expand Down Expand Up @@ -268,7 +268,7 @@ async def select_sources_sub_table(
async def patch_sources_sub_table(
engine: AsyncEngine,
table_id: int,
geometry_type: Literal["polygons", "points", "linestrings"],
geometry_type: Literal["polygons", "points", "lines"],
update_values: dict,
query_params: list = None
) -> CursorResult:
Expand Down
12 changes: 6 additions & 6 deletions api/routes/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def get_sub_sources_geometries(
engine = get_engine()
async with engine.begin() as conn:

for geometry in ["polygons", "linestrings", "points"]:
for geometry in ["polygons", "lines", "points"]:

try:
table = await get_table(conn, table_id, geometry)
Expand All @@ -153,7 +153,7 @@ async def get_sub_sources_helper(
response: Response,
request: starlette.requests.Request,
table_id: int,
geometry_type: Literal["polygons", "linestrings", "points"],
geometry_type: Literal["polygons", "lines", "points"],
page: int = 0,
page_size: int = 100
) -> List[Union[PolygonResponseModel, LineStringModel, PointModel]]:
Expand Down Expand Up @@ -210,22 +210,22 @@ async def get_sub_sources(
return await get_sub_sources_helper(response, request, table_id, "points", page, page_size)


@router.get("/{table_id}/linestrings", response_model=List[LineStringModel])
@router.get("/{table_id}/lines", response_model=List[LineStringModel])
async def get_sub_sources(
response: Response,
request: starlette.requests.Request,
table_id: int,
page: int = 0,
page_size: int = 100
):
return await get_sub_sources_helper(response, request, table_id, "linestrings", page, page_size)
return await get_sub_sources_helper(response, request, table_id, "lines", page, page_size)


@router.patch("/{table_id}/{geometry_type}")
async def patch_sub_sources(
request: starlette.requests.Request,
table_id: int,
geometry_type: Literal["polygons", "linestrings", "points"],
geometry_type: Literal["polygons", "lines", "points"],
updates: Union[PolygonRequestModel, LineStringModel, PointModel],
user_has_access: bool = Depends(has_access)
) -> List[Union[PolygonResponseModel, LineStringModel, PointModel]]:
Expand Down Expand Up @@ -259,7 +259,7 @@ async def patch_sub_sources(
request: starlette.requests.Request,
target_column: str,
table_id: int,
geometry_type: Literal["polygons", "linestrings", "points"],
geometry_type: Literal["polygons", "lines", "points"],
copy_column: CopyColumnRequest,
user_has_access: bool = Depends(has_access),
):
Expand Down
4 changes: 2 additions & 2 deletions api/tests/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ def test_get_sources_points_table(self, api_client: TestClient):

assert len(response_json) > 0

def test_get_source_linestrings_table(self, api_client: TestClient):
response = api_client.get(f"/sources/{TEST_SOURCE_TABLE.source_id}/linestrings")
def test_get_source_lines_table(self, api_client: TestClient):
response = api_client.get(f"/sources/{TEST_SOURCE_TABLE.source_id}/lines")
assert response.status_code == 200
response_json = response.json()

Expand Down

0 comments on commit a8ada79

Please sign in to comment.