Auto-update: Tue Jul 30 15:22:09 PDT 2024

This commit is contained in:
sanj 2024-07-30 15:22:09 -07:00
parent d7020c2a0a
commit d2e54009e0

View file

@ -655,12 +655,13 @@ class APIConfig(BaseModel):
{', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col != 'id')} {', '.join(f"{col} = EXCLUDED.{col}" for col in columns if col != 'id')}
""" """
# Execute the insert for each change # Execute the insert for all changes in a single transaction
affected_rows = 0 async with conn.transaction():
for change in changes: affected_rows = 0
values = [change[col] for col in columns] for change in changes:
result = await conn.execute(insert_query, *values) values = [change[col] for col in columns]
affected_rows += int(result.split()[-1]) result = await conn.execute(insert_query, *values)
affected_rows += int(result.split()[-1])
return affected_rows return affected_rows
@ -670,6 +671,7 @@ class APIConfig(BaseModel):
return 0 return 0
async def push_changes_to_all(self): async def push_changes_to_all(self):
for pool_entry in self.POOL: for pool_entry in self.POOL:
if pool_entry['ts_id'] != os.environ.get('TS_ID'): if pool_entry['ts_id'] != os.environ.get('TS_ID'):