Skip to content

Commit da97cf3

Browse files
committed
bulk transactions
1 parent db9e533 commit da97cf3

File tree

1 file changed

+32
-3
lines changed
  • stac_fastapi/elasticsearch/stac_fastapi/elasticsearch

1 file changed

+32
-3
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/core.py

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,12 @@ async def delete_collection(
654654

655655
@attr.s
656656
class BulkTransactionsClient(BaseBulkTransactionsClient):
657-
"""Postgres bulk transactions."""
657+
"""A client for posting bulk transactions to a Postgres database.
658+
659+
Attributes:
660+
session: An instance of `Session` to use for database connection.
661+
database: An instance of `DatabaseLogic` to perform database operations.
662+
"""
658663

659664
session: Session = attr.ib(default=attr.Factory(Session.create_from_env))
660665
database = DatabaseLogic()
@@ -665,14 +670,31 @@ def __attrs_post_init__(self):
665670
self.client = settings.create_client
666671

667672
def preprocess_item(self, item: stac_types.Item, base_url) -> stac_types.Item:
668-
"""Preprocess items to match data model."""
673+
"""Preprocess an item to match the data model.
674+
675+
Args:
676+
item: The item to preprocess.
677+
base_url: The base URL of the request.
678+
679+
Returns:
680+
The preprocessed item.
681+
"""
669682
return self.database.sync_prep_create_item(item=item, base_url=base_url)
670683

671684
@overrides
672685
def bulk_item_insert(
673686
self, items: Items, chunk_size: Optional[int] = None, **kwargs
674687
) -> str:
675-
"""Bulk item insertion using es."""
688+
"""Perform a bulk insertion of items into the database using Elasticsearch.
689+
690+
Args:
691+
items: The items to insert.
692+
chunk_size: The size of each chunk for bulk processing.
693+
**kwargs: Additional keyword arguments, such as `request` and `refresh`.
694+
695+
Returns:
696+
A string indicating the number of items successfully added.
697+
"""
676698
request = kwargs.get("request")
677699
if request:
678700
base_url = str(request.base_url)
@@ -710,6 +732,13 @@ async def get_queryables(
710732
under OGC CQL but it is allowed by the STAC API Filter Extension
711733
712734
https://github.com/radiantearth/stac-api-spec/tree/master/fragments/filter#queryables
735+
736+
Args:
737+
collection_id (str, optional): The id of the collection to get queryables for.
738+
**kwargs: additional keyword arguments
739+
740+
Returns:
741+
Dict[str, Any]: A dictionary containing the queryables for the given collection.
713742
"""
714743
return {
715744
"$schema": "https://json-schema.org/draft/2019-09/schema",

0 commit comments

Comments
 (0)