diff options
author | Mark Haines <mark.haines@matrix.org> | 2015-04-30 16:54:55 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2015-04-30 16:54:55 +0100 |
commit | 2d4d2bbae4f35e3128fa492e45cfc5b0750524bc (patch) | |
tree | 8e3fa03a60443dc2a1af80d5fb13aa0e28ffddca /synapse/storage/appservice.py | |
parent | Write a default log_config when generating config (diff) | |
parent | Add get_rooms_for_user cache (diff) | |
download | synapse-2d4d2bbae4f35e3128fa492e45cfc5b0750524bc.tar.xz |
Merge branch 'develop' into markjh/config_cleanup
Conflicts: synapse/config/captcha.py
Diffstat (limited to 'synapse/storage/appservice.py')
-rw-r--r-- | synapse/storage/appservice.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/synapse/storage/appservice.py b/synapse/storage/appservice.py index 63d1af4e86..39b7881c40 100644 --- a/synapse/storage/appservice.py +++ b/synapse/storage/appservice.py @@ -355,11 +355,11 @@ class ApplicationServiceTransactionStore(SQLBaseStore): # being sent) last_txn_id = self._get_last_txn(txn, service.id) - result = txn.execute( + txn.execute( "SELECT MAX(txn_id) FROM application_services_txns WHERE as_id=?", (service.id,) ) - highest_txn_id = result.fetchone()[0] + highest_txn_id = txn.fetchone()[0] if highest_txn_id is None: highest_txn_id = 0 @@ -441,15 +441,17 @@ class ApplicationServiceTransactionStore(SQLBaseStore): def _get_oldest_unsent_txn(self, txn, service): # Monotonically increasing txn ids, so just select the smallest # one in the txns table (we delete them when they are sent) - result = txn.execute( - "SELECT MIN(txn_id), * FROM application_services_txns WHERE as_id=?", + txn.execute( + "SELECT * FROM application_services_txns WHERE as_id=?" + " ORDER BY txn_id ASC LIMIT 1", (service.id,) ) - entry = self.cursor_to_dict(result)[0] - if not entry or entry["txn_id"] is None: - # the min(txn_id) part will force a row, so entry may not be None + rows = self.cursor_to_dict(txn) + if not rows: return None + entry = rows[0] + event_ids = json.loads(entry["event_ids"]) events = self._get_events_txn(txn, event_ids) @@ -458,11 +460,11 @@ class ApplicationServiceTransactionStore(SQLBaseStore): ) def _get_last_txn(self, txn, service_id): - result = txn.execute( + txn.execute( "SELECT last_txn FROM application_services_state WHERE as_id=?", (service_id,) ) - last_txn_id = result.fetchone() + last_txn_id = txn.fetchone() if last_txn_id is None or last_txn_id[0] is None: # no row exists return 0 else: |