mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-07-20 21:18:44 -04:00
Improvements to bundling aggregations. (#11815)
This is some odds and ends found during the review of #11791 and while continuing to work in this code: * Return attrs classes instead of dictionaries from some methods to improve type safety. * Call `get_bundled_aggregations` fewer times. * Adds a missing assertion in the tests. * Do not return empty bundled aggregations for an event (preferring to not include the bundle at all, as the docstring states).
This commit is contained in:
parent
d8df8e6c14
commit
2897fb6b4f
12 changed files with 212 additions and 139 deletions
|
@ -81,6 +81,14 @@ class _EventDictReturn:
|
|||
stream_ordering: int
|
||||
|
||||
|
||||
@attr.s(slots=True, frozen=True, auto_attribs=True)
|
||||
class _EventsAround:
|
||||
events_before: List[EventBase]
|
||||
events_after: List[EventBase]
|
||||
start: RoomStreamToken
|
||||
end: RoomStreamToken
|
||||
|
||||
|
||||
def generate_pagination_where_clause(
|
||||
direction: str,
|
||||
column_names: Tuple[str, str],
|
||||
|
@ -846,7 +854,7 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
before_limit: int,
|
||||
after_limit: int,
|
||||
event_filter: Optional[Filter] = None,
|
||||
) -> dict:
|
||||
) -> _EventsAround:
|
||||
"""Retrieve events and pagination tokens around a given event in a
|
||||
room.
|
||||
"""
|
||||
|
@ -869,12 +877,12 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore):
|
|||
list(results["after"]["event_ids"]), get_prev_content=True
|
||||
)
|
||||
|
||||
return {
|
||||
"events_before": events_before,
|
||||
"events_after": events_after,
|
||||
"start": results["before"]["token"],
|
||||
"end": results["after"]["token"],
|
||||
}
|
||||
return _EventsAround(
|
||||
events_before=events_before,
|
||||
events_after=events_after,
|
||||
start=results["before"]["token"],
|
||||
end=results["after"]["token"],
|
||||
)
|
||||
|
||||
def _get_events_around_txn(
|
||||
self,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue