make it work

This commit is contained in:
Matthew Hodgson 2018-03-13 22:31:41 +00:00
parent f0f9a0605b
commit ccca02846d
2 changed files with 9 additions and 7 deletions

View File

@ -498,7 +498,7 @@ class SyncHandler(object):
if filter_members: if filter_members:
member_state_ids = { member_state_ids = {
t: state_ids[t] t: state_ids[t]
for t in state_ids if t[0] == EventTypes.member for t in state_ids if t[0] == EventTypes.Member
} }
else: else:
@ -511,7 +511,7 @@ class SyncHandler(object):
if filter_members: if filter_members:
member_state_ids = { member_state_ids = {
t: state_ids[t] t: state_ids[t]
for t in state_ids if t[0] == EventTypes.member for t in state_ids if t[0] == EventTypes.Member
} }
timeline_state = { timeline_state = {
@ -542,7 +542,7 @@ class SyncHandler(object):
if filter_members: if filter_members:
member_state_ids = { member_state_ids = {
t: state_at_timeline_start[t] t: state_at_timeline_start[t]
for t in state_ids if t[0] == EventTypes.member for t in state_ids if t[0] == EventTypes.Member
} }
timeline_state = { timeline_state = {

View File

@ -257,10 +257,11 @@ class StateGroupWorkerStore(SQLBaseStore):
if include_other_types: if include_other_types:
# XXX: check whether this slows postgres down like a list of # XXX: check whether this slows postgres down like a list of
# ORs does too? # ORs does too?
unique_types = set([ t for (t, _) in types ])
clause_to_args.append( clause_to_args.append(
( (
"AND type <> ? " * len(types), "AND type <> ? " * len(unique_types),
[t for (t, _) in types] list(unique_types)
) )
) )
else: else:
@ -293,10 +294,11 @@ class StateGroupWorkerStore(SQLBaseStore):
where_args.extend([typ[0], typ[1]]) where_args.extend([typ[0], typ[1]])
if include_other_types: if include_other_types:
unique_types = set([ t for (t, _) in types ])
where_clauses.append( where_clauses.append(
"(" + " AND ".join(["type <> ?"] * len(types)) + ")" "(" + " AND ".join(["type <> ?"] * len(unique_types)) + ")"
) )
where_args.extend(t for (t, _) in types) where_args.extend(list(unique_types))
where_clause = "AND (%s)" % (" OR ".join(where_clauses)) where_clause = "AND (%s)" % (" OR ".join(where_clauses))
else: else: