diff options
author | Erik Johnston <erik@matrix.org> | 2014-12-09 13:35:26 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2014-12-09 13:35:26 +0000 |
commit | aa3f66cf7ff15b292afc6f251c1a77e154b8b675 (patch) | |
tree | 7247c1b6860cc5c5581f169a58f394e1dd81c103 /synapse/storage/_base.py | |
parent | Delete test file (diff) | |
download | synapse-aa3f66cf7ff15b292afc6f251c1a77e154b8b675.tar.xz |
Change the way we implement get_events to be less sucky
Diffstat (limited to 'synapse/storage/_base.py')
-rw-r--r-- | synapse/storage/_base.py | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index b0f454b90b..72f88cb2aa 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -461,32 +461,18 @@ class SQLBaseStore(object): **d ) - def _get_events_txn(self, txn, event_ids): - # FIXME (erikj): This should be batched? - - sql = "SELECT * FROM events WHERE event_id = ? ORDER BY rowid asc" - - event_rows = [] - for e_id in event_ids: - c = txn.execute(sql, (e_id,)) - event_rows.extend(self.cursor_to_dict(c)) - - return self._parse_events_txn(txn, event_rows) - - def _parse_events(self, rows): + def _get_events(self, event_ids): return self.runInteraction( - "_parse_events", self._parse_events_txn, rows + "_get_events", self._get_events_txn, event_ids ) - def _parse_events_txn(self, txn, rows): - event_ids = [r["event_id"] for r in rows] - + def _get_events_txn(self, txn, event_ids): events = [] - for event_id in event_ids: + for e_id in event_ids: js = self._simple_select_one_onecol_txn( txn, table="event_json", - keyvalues={"event_id": event_id}, + keyvalues={"event_id": e_id}, retcol="json", allow_none=True, ) @@ -516,6 +502,16 @@ class SQLBaseStore(object): return events + def _parse_events(self, rows): + return self.runInteraction( + "_parse_events", self._parse_events_txn, rows + ) + + def _parse_events_txn(self, txn, rows): + event_ids = [r["event_id"] for r in rows] + + return self._get_events_txn(txn, event_ids) + def _has_been_redacted_txn(self, txn, event): sql = "SELECT event_id FROM redactions WHERE redacts = ?" txn.execute(sql, (event.event_id,)) |