mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-20 11:54:18 -05:00
Remove duplication
This commit is contained in:
parent
13122e5e24
commit
4974147aa3
@ -386,38 +386,26 @@ class StateStore(SQLBaseStore):
|
|||||||
# each (type, state_key). However, that was terribly slow
|
# each (type, state_key). However, that was terribly slow
|
||||||
# without the right indicies (which we can't add until
|
# without the right indicies (which we can't add until
|
||||||
# after we finish deduping state, which requires this func)
|
# after we finish deduping state, which requires this func)
|
||||||
if types is not None:
|
args = [next_group]
|
||||||
args = [next_group] + [i for typ in types for i in typ]
|
if types:
|
||||||
txn.execute(
|
args.extend(i for typ in types for i in typ)
|
||||||
"SELECT type, state_key, event_id FROM state_groups_state"
|
|
||||||
" WHERE state_group = ? %s" % (where_clause,),
|
|
||||||
args
|
|
||||||
)
|
|
||||||
rows = txn.fetchall()
|
|
||||||
|
|
||||||
results[group].update({
|
txn.execute(
|
||||||
(typ, state_key): event_id
|
"SELECT type, state_key, event_id FROM state_groups_state"
|
||||||
for typ, state_key, event_id in rows
|
" WHERE state_group = ? %s" % (where_clause,),
|
||||||
if (typ, state_key) not in results[group]
|
args
|
||||||
})
|
)
|
||||||
|
rows = txn.fetchall()
|
||||||
|
results[group].update({
|
||||||
|
(typ, state_key): event_id
|
||||||
|
for typ, state_key, event_id in rows
|
||||||
|
if (typ, state_key) not in results[group]
|
||||||
|
})
|
||||||
|
|
||||||
# If the lengths match then we must have all the types,
|
# If the lengths match then we must have all the types,
|
||||||
# so no need to go walk further down the tree.
|
# so no need to go walk further down the tree.
|
||||||
if len(results[group]) == len(types):
|
if types is not None and len(results[group]) == len(types):
|
||||||
break
|
break
|
||||||
else:
|
|
||||||
txn.execute(
|
|
||||||
"SELECT type, state_key, event_id FROM state_groups_state"
|
|
||||||
" WHERE state_group = ?",
|
|
||||||
(next_group,)
|
|
||||||
)
|
|
||||||
rows = txn.fetchall()
|
|
||||||
|
|
||||||
results[group].update({
|
|
||||||
(typ, state_key): event_id
|
|
||||||
for typ, state_key, event_id in rows
|
|
||||||
if (typ, state_key) not in results[group]
|
|
||||||
})
|
|
||||||
|
|
||||||
next_group = self._simple_select_one_onecol_txn(
|
next_group = self._simple_select_one_onecol_txn(
|
||||||
txn,
|
txn,
|
||||||
|
Loading…
Reference in New Issue
Block a user