Compare commits

...

4 commits

Author SHA1 Message Date
Matthew Hodgson a4590a9ba5 Merge branch 'develop' into matthew/fix_filtered_types_in_current_state 2018-09-19 09:34:01 +01:00
Matthew Hodgson fe74bf31cc make this work 2018-09-10 17:14:18 +01:00
Matthew Hodgson 040f14b5d4 changelog 2018-09-04 23:20:49 +01:00
Matthew Hodgson 7afd63cdfc this will never have worked due to the query being split up into separate queries. 2018-09-04 23:14:33 +01:00
2 changed files with 7 additions and 7 deletions

1
changelog.d/3792.bugfix Normal file
View file

@ -0,0 +1 @@
Fix get_filtered_current_state_ids()s usage of filtered_type

View file

@ -151,7 +151,7 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
_get_current_state_ids_txn,
)
# FIXME: how should this be cached?
# FIXME: we should cache this if it turns out to be hit too often by /members
def get_filtered_current_state_ids(self, room_id, types, filtered_types=None):
"""Get the current state event of a given type for a room based on the
current_state_events table. This may not be as up-to-date as the result
@ -175,6 +175,7 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
# Turns out that postgres doesn't like doing a list of OR's and
# is about 1000x slower, so we just issue a query for each specific
# type seperately.
additional_args = ()
if types:
clause_to_args = [
(
@ -189,19 +190,17 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
if include_other_types:
unique_types = set(filtered_types)
clause_to_args.append(
(
"AND type <> ? " * len(unique_types),
list(unique_types)
)
)
sql += " AND type <> ? " * len(unique_types)
additional_args = list(unique_types)
else:
# If types is None we fetch all the state, and so just use an
# empty where clause with no extra args.
clause_to_args = [("", [])]
for where_clause, where_args in clause_to_args:
args = [room_id]
args.extend(where_args)
args.extend(additional_args)
txn.execute(sql % (where_clause,), args)
for row in txn:
typ, state_key, event_id = row