Skip to content

Commit f62de17

Browse files
committed
fix bulk sync
1 parent d7b0668 commit f62de17

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/database_logic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ def delete_item(self, item_id: str, collection_id: str):
275275
)
276276

277277
def create_collection(self, collection: stac_types.Collection):
278+
"""Database logic for creating one collection."""
278279
if self.client.exists(index=COLLECTIONS_INDEX, id=collection["id"]):
279280
raise ConflictError(f"Collection {collection['id']} already exists")
280281

@@ -285,20 +286,22 @@ def create_collection(self, collection: stac_types.Collection):
285286
)
286287

287288
def prep_update_collection(self, collection_id: str):
289+
"""Database logic for updating a collection."""
288290
try:
289291
_ = self.client.get(index=COLLECTIONS_INDEX, id=collection_id)
290292
except elasticsearch.exceptions.NotFoundError:
291293
raise NotFoundError(f"Collection {collection_id} not found")
292294

293295
def delete_collection(self, collection_id: str):
296+
"""Database logic for deleting one collection."""
294297
try:
295298
_ = self.client.get(index=COLLECTIONS_INDEX, id=collection_id)
296299
except elasticsearch.exceptions.NotFoundError:
297300
raise NotFoundError(f"Collection {collection_id} not found")
298301
self.client.delete(index=COLLECTIONS_INDEX, id=collection_id)
299302

300-
def bulk_sync(self, processed_items):
301-
"""Database logic for bulk insertion."""
303+
def bulk_sync(self, processed_items):
304+
"""Database logic for bulk item insertion."""
302305
actions = [
303306
{
304307
"_index": ITEMS_INDEX,

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
4949
bulk_client.preprocess_item(item, base_url) for item in item["features"]
5050
]
5151
return_msg = f"Successfully added {len(processed_items)} items."
52-
bulk_client.bulk_sync(processed_items)
52+
self.database.bulk_sync(processed_items)
5353

5454
return return_msg
5555
else:

0 commit comments

Comments
 (0)