mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-26 19:47:05 +03:00
Check that somethign has happend before running the selects
This commit is contained in:
parent
71df327190
commit
871357d539
3 changed files with 14 additions and 2 deletions
|
@ -1143,6 +1143,12 @@ class EventsStore(SQLBaseStore):
|
||||||
current_backfill_id, current_forward_id, limit):
|
current_backfill_id, current_forward_id, limit):
|
||||||
"""Get all the new events that have arrived at the server either as
|
"""Get all the new events that have arrived at the server either as
|
||||||
new events or as backfilled events"""
|
new events or as backfilled events"""
|
||||||
|
have_backfill_events = last_backfill_id != current_backfill_id
|
||||||
|
have_forward_events = last_forward_id != current_forward_id
|
||||||
|
|
||||||
|
if not have_backfill_events and not have_forward_events:
|
||||||
|
return defer.succeed(AllNewEventsResult([], [], [], [], []))
|
||||||
|
|
||||||
def get_all_new_events_txn(txn):
|
def get_all_new_events_txn(txn):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT e.stream_ordering, ej.internal_metadata, ej.json, eg.state_group"
|
"SELECT e.stream_ordering, ej.internal_metadata, ej.json, eg.state_group"
|
||||||
|
@ -1155,7 +1161,7 @@ class EventsStore(SQLBaseStore):
|
||||||
" ORDER BY e.stream_ordering ASC"
|
" ORDER BY e.stream_ordering ASC"
|
||||||
" LIMIT ?"
|
" LIMIT ?"
|
||||||
)
|
)
|
||||||
if last_forward_id != current_forward_id:
|
if have_forward_events:
|
||||||
txn.execute(sql, (last_forward_id, current_forward_id, limit))
|
txn.execute(sql, (last_forward_id, current_forward_id, limit))
|
||||||
new_forward_events = txn.fetchall()
|
new_forward_events = txn.fetchall()
|
||||||
|
|
||||||
|
@ -1199,7 +1205,7 @@ class EventsStore(SQLBaseStore):
|
||||||
" ORDER BY e.stream_ordering DESC"
|
" ORDER BY e.stream_ordering DESC"
|
||||||
" LIMIT ?"
|
" LIMIT ?"
|
||||||
)
|
)
|
||||||
if last_backfill_id != current_backfill_id:
|
if have_backfill_events:
|
||||||
txn.execute(sql, (-last_backfill_id, -current_backfill_id, limit))
|
txn.execute(sql, (-last_backfill_id, -current_backfill_id, limit))
|
||||||
new_backfill_events = txn.fetchall()
|
new_backfill_events = txn.fetchall()
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,9 @@ class PusherStore(SQLBaseStore):
|
||||||
return self._pushers_id_gen.get_current_token()
|
return self._pushers_id_gen.get_current_token()
|
||||||
|
|
||||||
def get_all_updated_pushers(self, last_id, current_id, limit):
|
def get_all_updated_pushers(self, last_id, current_id, limit):
|
||||||
|
if last_id == current_id:
|
||||||
|
return defer.succeed(([], []))
|
||||||
|
|
||||||
def get_all_updated_pushers_txn(txn):
|
def get_all_updated_pushers_txn(txn):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT id, user_name, access_token, profile_tag, kind,"
|
"SELECT id, user_name, access_token, profile_tag, kind,"
|
||||||
|
|
|
@ -391,6 +391,9 @@ class ReceiptsStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_all_updated_receipts(self, last_id, current_id, limit=None):
|
def get_all_updated_receipts(self, last_id, current_id, limit=None):
|
||||||
|
if last_id == current_id:
|
||||||
|
return defer.succeed([])
|
||||||
|
|
||||||
def get_all_updated_receipts_txn(txn):
|
def get_all_updated_receipts_txn(txn):
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT stream_id, room_id, receipt_type, user_id, event_id, data"
|
"SELECT stream_id, room_id, receipt_type, user_id, event_id, data"
|
||||||
|
|
Loading…
Reference in a new issue