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

Commit

Permalink
Merge pull request #3200 from matrix-org/erikj/remove_membership_change
Browse files Browse the repository at this point in the history
 Remove unused code path from member change DB func
  • Loading branch information
erikjohnston authored May 9, 2018
2 parents 1e5280b + cddf91c commit a5c98dd
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions synapse/storage/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,7 @@ def f(txn):

@defer.inlineCallbacks
def get_membership_changes_for_user(self, user_id, from_key, to_key):
if from_key is not None:
from_id = RoomStreamToken.parse_stream_token(from_key).stream
else:
from_id = None
from_id = RoomStreamToken.parse_stream_token(from_key).stream
to_id = RoomStreamToken.parse_stream_token(to_key).stream

if from_key == to_key:
Expand All @@ -321,26 +318,15 @@ def get_membership_changes_for_user(self, user_id, from_key, to_key):
defer.returnValue([])

def f(txn):
if from_id is not None:
sql = (
"SELECT m.event_id, stream_ordering FROM events AS e,"
" room_memberships AS m"
" WHERE e.event_id = m.event_id"
" AND m.user_id = ?"
" AND e.stream_ordering > ? AND e.stream_ordering <= ?"
" ORDER BY e.stream_ordering ASC"
)
txn.execute(sql, (user_id, from_id, to_id,))
else:
sql = (
"SELECT m.event_id, stream_ordering FROM events AS e,"
" room_memberships AS m"
" WHERE e.event_id = m.event_id"
" AND m.user_id = ?"
" AND stream_ordering <= ?"
" ORDER BY stream_ordering ASC"
)
txn.execute(sql, (user_id, to_id,))
sql = (
"SELECT m.event_id, stream_ordering FROM events AS e,"
" room_memberships AS m"
" WHERE e.event_id = m.event_id"
" AND m.user_id = ?"
" AND e.stream_ordering > ? AND e.stream_ordering <= ?"
" ORDER BY e.stream_ordering ASC"
)
txn.execute(sql, (user_id, from_id, to_id,))

rows = [_EventDictReturn(row[0], None, row[1]) for row in txn]

Expand Down

0 comments on commit a5c98dd

Please sign in to comment.