Skip to content

Commit f9bf949

Browse files
committed
collection serializer
1 parent b81ab30 commit f9bf949

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

stac_fastapi/core/stac_fastapi/core/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ async def all_collections(self, **kwargs) -> Collections:
204204
token = request.query_params.get("token")
205205

206206
collections, next_token = await self.database.get_all_collections(
207-
token=token, limit=limit
207+
token=token, limit=limit, base_url=base_url
208208
)
209209

210210
links = [
@@ -238,7 +238,9 @@ async def get_collection(self, collection_id: str, **kwargs) -> Collection:
238238
"""
239239
base_url = str(kwargs["request"].base_url)
240240
collection = await self.database.find_collection(collection_id=collection_id)
241-
return self.collection_serializer.db_to_stac(collection, base_url)
241+
return self.collection_serializer.db_to_stac(
242+
collection=collection, base_url=base_url
243+
)
242244

243245
async def item_collection(
244246
self,

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class DatabaseLogic:
290290
"""CORE LOGIC"""
291291

292292
async def get_all_collections(
293-
self, token: Optional[str], limit: int
293+
self, token: Optional[str], limit: int, base_url: str
294294
) -> Tuple[List[Dict[str, Any]], Optional[str]]:
295295
"""Retrieve a list of all collections from Elasticsearch, supporting pagination.
296296
@@ -315,7 +315,12 @@ async def get_all_collections(
315315
)
316316

317317
hits = response["hits"]["hits"]
318-
collections = [hit["_source"] for hit in hits]
318+
collections = [
319+
self.collection_serializer.db_to_stac(
320+
collection=hit["_source"], base_url=base_url
321+
)
322+
for hit in hits
323+
]
319324

320325
next_token = None
321326
if len(hits) == limit:

stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class DatabaseLogic:
311311
"""CORE LOGIC"""
312312

313313
async def get_all_collections(
314-
self, token: Optional[str], limit: int
314+
self, token: Optional[str], limit: int, base_url: str
315315
) -> Tuple[List[Dict[str, Any]], Optional[str]]:
316316
"""
317317
Retrieve a list of all collections from Opensearch, supporting pagination.
@@ -339,7 +339,12 @@ async def get_all_collections(
339339
)
340340

341341
hits = response["hits"]["hits"]
342-
collections = [hit["_source"] for hit in hits]
342+
collections = [
343+
self.collection_serializer.db_to_stac(
344+
collection=hit["_source"], base_url=base_url
345+
)
346+
for hit in hits
347+
]
343348

344349
next_token = None
345350
if len(hits) == limit:

0 commit comments

Comments
 (0)