Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Back to using cursor_to_dict
Browse files Browse the repository at this point in the history
  • Loading branch information
babolivier committed Nov 7, 2019
1 parent ec2cb9f commit 1186612
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions synapse/storage/data_stores/main/events_bg_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,13 @@ def _event_store_labels_txn(txn):
(last_event_id, batch_size),
)

nbrows = 0
last_row_event_id = ""
for (event_id, event_json_raw) in txn:
event_json = json.loads(event_json_raw)
rows = self.cursor_to_dict(txn)
if not len(rows):
return 0

for row in rows:
event_id = row["event_id"]
event_json = json.loads(row["event_json"])

self._simple_insert_many_txn(
txn=txn,
Expand All @@ -547,14 +550,11 @@ def _event_store_labels_txn(txn):
],
)

nbrows += 1
last_row_event_id = event_id

self._background_update_progress_txn(
txn, "event_store_labels", {"last_event_id": last_row_event_id}
txn, "event_store_labels", {"last_event_id": event_id}
)

return nbrows
return len(rows)

num_rows = yield self.runInteraction(
desc="event_store_labels", func=_event_store_labels_txn
Expand Down

0 comments on commit 1186612

Please sign in to comment.