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 #656 from matrix-org/erikj/get_event
Browse files Browse the repository at this point in the history
Dedupe requested event list in _get_events
  • Loading branch information
erikjohnston committed Mar 18, 2016
2 parents 916227b + 8595ff7 commit 7f79a64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 3 additions & 1 deletion synapse/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,7 @@ def __str__(self):

def __repr__(self):
return "<FrozenEvent event_id='%s', type='%s', state_key='%s'>" % (
self.event_id, self.type, self.get("state_key", None),
self.get("event_id", None),
self.get("type", None),
self.get("state_key", None),
)
26 changes: 12 additions & 14 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ def _get_events(self, event_ids, check_redacted=True,
if not event_ids:
defer.returnValue([])

event_id_list = event_ids
event_ids = set(event_ids)

event_map = self._get_events_from_cache(
event_ids,
check_redacted=check_redacted,
Expand All @@ -535,23 +538,18 @@ def _get_events(self, event_ids, check_redacted=True,

missing_events_ids = [e for e in event_ids if e not in event_map]

if not missing_events_ids:
defer.returnValue([
event_map[e_id] for e_id in event_ids
if e_id in event_map and event_map[e_id]
])

missing_events = yield self._enqueue_events(
missing_events_ids,
check_redacted=check_redacted,
get_prev_content=get_prev_content,
allow_rejected=allow_rejected,
)
if missing_events_ids:
missing_events = yield self._enqueue_events(
missing_events_ids,
check_redacted=check_redacted,
get_prev_content=get_prev_content,
allow_rejected=allow_rejected,
)

event_map.update(missing_events)
event_map.update(missing_events)

defer.returnValue([
event_map[e_id] for e_id in event_ids
event_map[e_id] for e_id in event_id_list
if e_id in event_map and event_map[e_id]
])

Expand Down

0 comments on commit 7f79a64

Please sign in to comment.