Skip to content

Commit 1d0aac8

Browse files
author
Phil Varner
committed
un-rearrange code
1 parent 4d3a160 commit 1d0aac8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/transactions.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,17 @@ def create_item(self, item: stac_types.Item, **kwargs) -> stac_types.Item:
4949

5050
return return_msg
5151
else:
52-
# TODO
52+
# todo: check if collection exists, but cache
53+
if not self.client.exists(index=COLLECTIONS_INDEX, id=item["collection"]):
54+
raise ForeignKeyError(f"Collection {item['collection']} does not exist")
55+
5356
if self.client.exists(
5457
index=ITEMS_INDEX, id=mk_item_id(item["id"], item["collection"])
5558
):
5659
raise ConflictError(
5760
f"Item {item['id']} in collection {item['collection']} already exists"
5861
)
5962

60-
# todo: check if collection exists, but cache
61-
if not self.client.exists(index=COLLECTIONS_INDEX, id=item["collection"]):
62-
raise ForeignKeyError(f"Collection {item['collection']} does not exist")
63-
6463
item = BulkTransactionsClient().preprocess_item(item, base_url)
6564

6665
es_resp = self.client.index(

0 commit comments

Comments
 (0)