Skip to content

Commit a78a138

Browse files
author
Edward Keeble
committed
Get bulk transactions method from items object. Avoid reassigning items variable.
1 parent 4c844f2 commit a78a138

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stac_fastapi/pgstac/transactions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,16 @@ class BulkTransactionsClient(AsyncBaseBulkTransactionsClient):
180180
"""Postgres bulk transactions."""
181181

182182
async def bulk_item_insert(
183-
self, items: Items, request: Request, method: BulkTransactionMethod, **kwargs
183+
self, items: Items, request: Request, **kwargs
184184
) -> str:
185185
"""Bulk item insertion using pgstac."""
186-
items = list(items.items.values())
186+
items_to_insert = list(items.items.values())
187187

188188
async with request.app.state.get_connection(request, "w") as conn:
189-
if method == BulkTransactionMethod.INSERT:
190-
await dbfunc(conn, "create_items", items)
191-
elif method == BulkTransactionMethod.UPSERT:
192-
await dbfunc(conn, "upsert_items", items)
189+
if items.method == BulkTransactionMethod.INSERT:
190+
await dbfunc(conn, "create_items", items_to_insert)
191+
elif items.method == BulkTransactionMethod.UPSERT:
192+
await dbfunc(conn, "upsert_items", items_to_insert)
193193

194-
return_msg = f"Successfully added {len(items)} items."
194+
return_msg = f"Successfully added {len(items_to_insert)} items."
195195
return return_msg

0 commit comments

Comments
 (0)