mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-16 03:12:23 -04:00
Make StreamToken.room_key
be a RoomStreamToken
instance. (#8281)
This commit is contained in:
parent
c312ee3cde
commit
fe8ed1b46f
16 changed files with 114 additions and 99 deletions
|
@ -213,7 +213,7 @@ class PersistEventsStore:
|
|||
Returns:
|
||||
Filtered event ids
|
||||
"""
|
||||
results = []
|
||||
results = [] # type: List[str]
|
||||
|
||||
def _get_events_which_are_prevs_txn(txn, batch):
|
||||
sql = """
|
||||
|
@ -631,7 +631,9 @@ class PersistEventsStore:
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def _filter_events_and_contexts_for_duplicates(cls, events_and_contexts):
|
||||
def _filter_events_and_contexts_for_duplicates(
|
||||
cls, events_and_contexts: List[Tuple[EventBase, EventContext]]
|
||||
) -> List[Tuple[EventBase, EventContext]]:
|
||||
"""Ensure that we don't have the same event twice.
|
||||
|
||||
Pick the earliest non-outlier if there is one, else the earliest one.
|
||||
|
@ -641,7 +643,9 @@ class PersistEventsStore:
|
|||
Returns:
|
||||
list[(EventBase, EventContext)]: filtered list
|
||||
"""
|
||||
new_events_and_contexts = OrderedDict()
|
||||
new_events_and_contexts = (
|
||||
OrderedDict()
|
||||
) # type: OrderedDict[str, Tuple[EventBase, EventContext]]
|
||||
for event, context in events_and_contexts:
|
||||
prev_event_context = new_events_and_contexts.get(event.event_id)
|
||||
if prev_event_context:
|
||||
|
@ -655,7 +659,12 @@ class PersistEventsStore:
|
|||
new_events_and_contexts[event.event_id] = (event, context)
|
||||
return list(new_events_and_contexts.values())
|
||||
|
||||
def _update_room_depths_txn(self, txn, events_and_contexts, backfilled):
|
||||
def _update_room_depths_txn(
|
||||
self,
|
||||
txn,
|
||||
events_and_contexts: List[Tuple[EventBase, EventContext]],
|
||||
backfilled: bool,
|
||||
):
|
||||
"""Update min_depth for each room
|
||||
|
||||
Args:
|
||||
|
@ -664,7 +673,7 @@ class PersistEventsStore:
|
|||
we are persisting
|
||||
backfilled (bool): True if the events were backfilled
|
||||
"""
|
||||
depth_updates = {}
|
||||
depth_updates = {} # type: Dict[str, int]
|
||||
for event, context in events_and_contexts:
|
||||
# Remove the any existing cache entries for the event_ids
|
||||
txn.call_after(self.store._invalidate_get_event_cache, event.event_id)
|
||||
|
@ -1436,7 +1445,7 @@ class PersistEventsStore:
|
|||
|
||||
Forward extremities are handled when we first start persisting the events.
|
||||
"""
|
||||
events_by_room = {}
|
||||
events_by_room = {} # type: Dict[str, List[EventBase]]
|
||||
for ev in events:
|
||||
events_by_room.setdefault(ev.room_id, []).append(ev)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue