mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 14:56:42 -04:00
Merge branch 'master' of github.com:matrix-org/synapse into sql_refactor
Conflicts: synapse/storage/_base.py
This commit is contained in:
commit
10294b6082
35 changed files with 412 additions and 188 deletions
|
@ -44,7 +44,6 @@ class DataStore(RoomDataStore, RoomMemberStore, MessageStore, RoomStore,
|
|||
def __init__(self, hs):
|
||||
super(DataStore, self).__init__(hs)
|
||||
self.event_factory = hs.get_event_factory()
|
||||
self.hs = hs
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def persist_event(self, event):
|
||||
|
|
|
@ -28,8 +28,10 @@ logger = logging.getLogger(__name__)
|
|||
class SQLBaseStore(object):
|
||||
|
||||
def __init__(self, hs):
|
||||
self.hs = hs
|
||||
self._db_pool = hs.get_db_pool()
|
||||
self.event_factory = hs.get_event_factory()
|
||||
self._clock = hs.get_clock()
|
||||
|
||||
def cursor_to_dict(self, cursor):
|
||||
"""Converts a SQL cursor into an list of dicts.
|
||||
|
|
|
@ -168,7 +168,7 @@ class PduStore(SQLBaseStore):
|
|||
|
||||
return self._get_pdu_tuples(txn, txn.fetchall())
|
||||
|
||||
def get_pagination(self, context, pdu_list, limit):
|
||||
def get_backfill(self, context, pdu_list, limit):
|
||||
"""Get a list of Pdus for a given topic that occured before (and
|
||||
including) the pdus in pdu_list. Return a list of max size `limit`.
|
||||
|
||||
|
@ -182,12 +182,12 @@ class PduStore(SQLBaseStore):
|
|||
list: A list of PduTuples
|
||||
"""
|
||||
return self._db_pool.runInteraction(
|
||||
self._get_paginate, context, pdu_list, limit
|
||||
self._get_backfill, context, pdu_list, limit
|
||||
)
|
||||
|
||||
def _get_paginate(self, txn, context, pdu_list, limit):
|
||||
def _get_backfill(self, txn, context, pdu_list, limit):
|
||||
logger.debug(
|
||||
"paginate: %s, %s, %s",
|
||||
"backfill: %s, %s, %s",
|
||||
context, repr(pdu_list), limit
|
||||
)
|
||||
|
||||
|
@ -213,7 +213,7 @@ class PduStore(SQLBaseStore):
|
|||
new_front = []
|
||||
for pdu_id, origin in front:
|
||||
logger.debug(
|
||||
"_paginate_interaction: i=%s, o=%s",
|
||||
"_backfill_interaction: i=%s, o=%s",
|
||||
pdu_id, origin
|
||||
)
|
||||
|
||||
|
@ -224,7 +224,7 @@ class PduStore(SQLBaseStore):
|
|||
|
||||
for row in txn.fetchall():
|
||||
logger.debug(
|
||||
"_paginate_interaction: got i=%s, o=%s",
|
||||
"_backfill_interaction: got i=%s, o=%s",
|
||||
*row
|
||||
)
|
||||
new_front.append(row)
|
||||
|
@ -262,7 +262,7 @@ class PduStore(SQLBaseStore):
|
|||
|
||||
def update_min_depth_for_context(self, context, depth):
|
||||
"""Update the minimum `depth` of the given context, which is the line
|
||||
where we stop paginating backwards on.
|
||||
on which we stop backfilling backwards.
|
||||
|
||||
Args:
|
||||
context (str)
|
||||
|
@ -320,9 +320,9 @@ class PduStore(SQLBaseStore):
|
|||
return [(row[0], row[1], row[2]) for row in results]
|
||||
|
||||
def get_oldest_pdus_in_context(self, context):
|
||||
"""Get a list of Pdus that we paginated beyond yet (and haven't seen).
|
||||
This list is used when we want to paginate backwards and is the list we
|
||||
send to the remote server.
|
||||
"""Get a list of Pdus that we haven't backfilled beyond yet (and haven't
|
||||
seen). This list is used when we want to backfill backwards and is the
|
||||
list we send to the remote server.
|
||||
|
||||
Args:
|
||||
txn
|
||||
|
|
|
@ -35,7 +35,7 @@ class PresenceStore(SQLBaseStore):
|
|||
return self._simple_select_one(
|
||||
table="presence",
|
||||
keyvalues={"user_id": user_localpart},
|
||||
retcols=["state", "status_msg"],
|
||||
retcols=["state", "status_msg", "mtime"],
|
||||
)
|
||||
|
||||
def set_presence_state(self, user_localpart, new_state):
|
||||
|
@ -43,7 +43,8 @@ class PresenceStore(SQLBaseStore):
|
|||
table="presence",
|
||||
keyvalues={"user_id": user_localpart},
|
||||
updatevalues={"state": new_state["state"],
|
||||
"status_msg": new_state["status_msg"]},
|
||||
"status_msg": new_state["status_msg"],
|
||||
"mtime": self._clock.time_msec()},
|
||||
retcols=["state"],
|
||||
)
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ CREATE TABLE IF NOT EXISTS presence(
|
|||
user_id INTEGER NOT NULL,
|
||||
state INTEGER,
|
||||
status_msg TEXT,
|
||||
mtime INTEGER, -- miliseconds since last state change
|
||||
FOREIGN KEY(user_id) REFERENCES users(id)
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue