From 8ef235c15b94ce9d2290dcda0d91d6a7273b0329 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Fri, 2 Aug 2019 12:00:57 +0200 Subject: [PATCH] Fix CI --- synapse/handlers/pagination.py | 1 - synapse/storage/room.py | 18 +++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/synapse/handlers/pagination.py b/synapse/handlers/pagination.py index eb08dfe8428b..c43717c32716 100644 --- a/synapse/handlers/pagination.py +++ b/synapse/handlers/pagination.py @@ -20,7 +20,6 @@ from synapse.api.constants import EventTypes, Membership from synapse.api.errors import SynapseError -from synapse.config._base import Config from synapse.storage.state import StateFilter from synapse.types import RoomStreamToken from synapse.util.async_helpers import ReadWriteLock diff --git a/synapse/storage/room.py b/synapse/storage/room.py index ec66bf036311..9cfa19d8dc70 100644 --- a/synapse/storage/room.py +++ b/synapse/storage/room.py @@ -229,9 +229,10 @@ def __init__(self, db_conn, hs): self.config = hs.config self.register_background_update_handler( - "users_set_deactivated_flag", self._background_insert_retention, + "insert_room_retention", self._background_insert_retention, ) + @defer.inlineCallbacks def _background_insert_retention(self, progress, batch_size): """Retrieves a list of all rooms within a range and inserts an entry for each of them into the room_retention table. @@ -245,12 +246,15 @@ def _background_insert_retention(self, progress, batch_size): def _background_insert_retention_txn(txn): txn.execute( """ - SELECT r.room_id, e.json as retention_content FROM rooms as r - LEFT OUTER JOIN current_state_events as s ON ( - r.room_id = s.room_id - AND s.type = '%s' + SELECT rooms.room_id, events.json FROM rooms + LEFT OUTER JOIN current_state_events AS state ON ( + rooms.room_id = state.room_id + AND state.type = '%s' ) - LEFT JOIN event_json as e ON (s.event_id = e.event_id); + LEFT JOIN event_json AS events ON (state.event_id = events.event_id) + WHERE rooms.room_id > ? + ORDER BY rooms.room_id ASC + LIMIT ?; """ % EventTypes.Retention, (last_room, batch_size) ) @@ -286,7 +290,7 @@ def _background_insert_retention_txn(txn): self._background_update_progress_txn( txn, "insert_room_retention", { - "room_id": rows[-1]["insert_room_retention"], + "room_id": rows[-1]["room_id"], } )