summary refs log tree commit diff
path: root/synapse/storage/presence.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-10-18 10:11:40 +0100
committerRichard van der Hoff <richard@matrix.org>2019-10-18 10:11:40 +0100
commit80003dfcd503a72cb4da515b17c3765faccc2ce6 (patch)
tree448fc279a9278566283721bb6a0c86f17efdbd36 /synapse/storage/presence.py
parentchangelog (diff)
parentRemove dead changelog file (diff)
downloadsynapse-80003dfcd503a72cb4da515b17c3765faccc2ce6.tar.xz
Merge remote-tracking branch 'origin/develop' into rav/event_auth/1
Diffstat (limited to 'synapse/storage/presence.py')
-rw-r--r--synapse/storage/presence.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/synapse/storage/presence.py b/synapse/storage/presence.py

index 5db6f2d84a..3a641f538b 100644 --- a/synapse/storage/presence.py +++ b/synapse/storage/presence.py
@@ -18,11 +18,10 @@ from collections import namedtuple from twisted.internet import defer from synapse.api.constants import PresenceState +from synapse.storage._base import SQLBaseStore, make_in_list_sql_clause from synapse.util import batch_iter from synapse.util.caches.descriptors import cached, cachedList -from ._base import SQLBaseStore - class UserPresenceState( namedtuple( @@ -119,14 +118,13 @@ class PresenceStore(SQLBaseStore): ) # Delete old rows to stop database from getting really big - sql = ( - "DELETE FROM presence_stream WHERE" " stream_id < ?" " AND user_id IN (%s)" - ) + sql = "DELETE FROM presence_stream WHERE stream_id < ? AND " for states in batch_iter(presence_states, 50): - args = [stream_id] - args.extend(s.user_id for s in states) - txn.execute(sql % (",".join("?" for _ in states),), args) + clause, args = make_in_list_sql_clause( + self.database_engine, "user_id", [s.user_id for s in states] + ) + txn.execute(sql + clause, [stream_id] + list(args)) def get_all_presence_updates(self, last_id, current_id): if last_id == current_id: