22 lines
750 B
Python
22 lines
750 B
Python
from indexer.config import BATCH_SIZE
|
|
|
|
|
|
def batch_log_events(cur, events: list):
|
|
"""
|
|
Batch INSERT eventů do file_events.
|
|
events: [{run_id, file_id, event_type, old_size, new_size, old_hash, new_hash}]
|
|
"""
|
|
if not events:
|
|
return
|
|
for i in range(0, len(events), BATCH_SIZE):
|
|
chunk = events[i:i + BATCH_SIZE]
|
|
cur.executemany(
|
|
"""INSERT INTO file_events
|
|
(run_id, file_id, event_type, old_size, new_size, old_hash, new_hash)
|
|
VALUES (%s, %s, %s, %s, %s, %s, %s)""",
|
|
[(e["run_id"], e["file_id"], e["event_type"],
|
|
e.get("old_size"), e.get("new_size"),
|
|
e.get("old_hash"), e.get("new_hash"))
|
|
for e in chunk]
|
|
)
|