Correctly loop over events_and_contexts

This commit is contained in:
Erik Johnston 2018-05-30 11:30:33 +01:00
parent 13dbcafb9b
commit 6c1d13a15a
1 changed files with 14 additions and 16 deletions

View File

@ -1115,19 +1115,19 @@ class EventsStore(EventsWorkerStore):
], ],
) )
if event.internal_metadata.is_outlier(): for event, _ in events_and_contexts:
chunk_id, _topo = None, 0 if event.internal_metadata.is_outlier():
else: chunk_id, _topo = None, 0
chunk_id, _topo = self._compute_chunk_id_txn( else:
txn, event.room_id, event.event_id, chunk_id, _topo = self._compute_chunk_id_txn(
[eid for eid, _ in event.prev_events], txn, event.room_id, event.event_id,
) [eid for eid, _ in event.prev_events],
)
self._simple_insert_many_txn( self._simple_insert_txn(
txn, txn,
table="events", table="events",
values=[ values={
{
"stream_ordering": event.internal_metadata.stream_ordering, "stream_ordering": event.internal_metadata.stream_ordering,
"chunk_id": chunk_id, "chunk_id": chunk_id,
"topological_ordering": event.depth, "topological_ordering": event.depth,
@ -1145,10 +1145,8 @@ class EventsStore(EventsWorkerStore):
"url" in event.content "url" in event.content
and isinstance(event.content["url"], basestring) and isinstance(event.content["url"], basestring)
), ),
} },
for event, _ in events_and_contexts )
],
)
def _store_rejected_events_txn(self, txn, events_and_contexts): def _store_rejected_events_txn(self, txn, events_and_contexts):
"""Add rows to the 'rejections' table for received events which were """Add rows to the 'rejections' table for received events which were