Skip to content

Commit 297576a

Browse files
committed
remove duplicate constraint check for usage insert
1 parent 324d128 commit 297576a

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

rctab/routers/accounting/usage.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,13 @@ async def insert_usage(all_usage: AllUsage) -> None:
7878
all_usage: Usage data to insert.
7979
"""
8080
usage_query = insert(accounting_models.usage)
81-
update_dict = {c.name: c for c in usage_query.excluded if not c.primary_key}
82-
on_duplicate_key_stmt = usage_query.on_conflict_do_update(
83-
index_elements=inspect(accounting_models.usage).primary_key,
84-
set_=update_dict,
85-
)
8681

8782
logger.info("Inserting usage data")
8883
insert_start = datetime.datetime.now()
8984

9085
await executemany(
9186
database,
92-
on_duplicate_key_stmt,
87+
usage_query,
9388
values=[i.model_dump() for i in all_usage.usage_list],
9489
)
9590
logger.info("Inserting usage data took %s", datetime.datetime.now() - insert_start)

0 commit comments

Comments
 (0)