diff --git a/api/openrailwaymap_api/facility_api.py b/api/openrailwaymap_api/facility_api.py index 6b591ae8..19ba84bd 100644 --- a/api/openrailwaymap_api/facility_api.py +++ b/api/openrailwaymap_api/facility_api.py @@ -1,7 +1,7 @@ from fastapi import HTTPException from starlette.status import HTTP_400_BAD_REQUEST -from api import MAX_LIMIT +# from api import MAX_LIMIT QUERY_PARAMETERS = ['q', 'name', 'ref', 'uic_ref'] @@ -46,11 +46,11 @@ async def __call__(self, *, q, name, ref, uic_ref, limit): HTTP_400_BAD_REQUEST, {'type': 'limit_not_integer', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'The provided limit cannot be parsed as an integer value.'} ) - if self.limit > MAX_LIMIT: - raise HTTPException( - HTTP_400_BAD_REQUEST, - {'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'} - ) + # if self.limit > MAX_LIMIT: + # raise HTTPException( + # HTTP_400_BAD_REQUEST, + # {'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'} + # ) if name: return await self.search_by_name(name) if ref: @@ -88,7 +88,7 @@ async def search_by_name(self, q): ) AS a ) AS b ORDER BY rank DESC NULLS LAST - LIMIT %2;""" + LIMIT $2;""" async with self.database.acquire() as connection: statement = await connection.prepare(sql_query) @@ -104,8 +104,8 @@ async def _search_by_ref(self, search_key, ref): sql_query = f"""SELECT DISTINCT ON (osm_id) {fields}, ST_X(ST_Transform(geom, 4326)) AS latitude, ST_Y(ST_Transform(geom, 4326)) AS longitude FROM openrailwaymap_ref - WHERE {search_key} = %s - LIMIT %s;""" + WHERE {search_key} = $1 + LIMIT $2;""" async with self.database.acquire() as connection: statement = await connection.prepare(sql_query) diff --git a/api/openrailwaymap_api/milestone_api.py b/api/openrailwaymap_api/milestone_api.py index b4cb8adc..2f341c2b 100644 --- a/api/openrailwaymap_api/milestone_api.py +++ b/api/openrailwaymap_api/milestone_api.py @@ -34,11 +34,11 @@ async def __call__(self, *, ref, position, limit): HTTP_400_BAD_REQUEST, {'type': 'limit_not_integer', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'The provided limit cannot be parsed as an integer value.'} ) - if limit > self.MAX_LIMIT: - raise HTTPException( - HTTP_400_BAD_REQUEST, - {'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'} - ) + # if limit > self.MAX_LIMIT: + # raise HTTPException( + # HTTP_400_BAD_REQUEST, + # {'type': 'limit_too_high', 'error': 'Invalid parameter value provided for parameter "limit".', 'detail': 'Limit is too high. Please set up your own instance to query everything.'} + # ) self.data = await self.get_milestones(position, ref, limit) return self.data