mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-07 02:44:57 -04:00
Refactor search code to reduce function size. (#11991)
Splits the search code into a few logical functions instead of a single unreadable function. There are also a few additional changes for readability. After refactoring it was clear to see there were some unused and unnecessary variables, which were simplified.
This commit is contained in:
parent
45f45404de
commit
e44f91d678
3 changed files with 436 additions and 227 deletions
|
@ -28,6 +28,7 @@ from synapse.storage.database import (
|
|||
)
|
||||
from synapse.storage.databases.main.events_worker import EventRedactBehaviour
|
||||
from synapse.storage.engines import PostgresEngine, Sqlite3Engine
|
||||
from synapse.types import JsonDict
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from synapse.server import HomeServer
|
||||
|
@ -381,17 +382,19 @@ class SearchStore(SearchBackgroundUpdateStore):
|
|||
):
|
||||
super().__init__(database, db_conn, hs)
|
||||
|
||||
async def search_msgs(self, room_ids, search_term, keys):
|
||||
async def search_msgs(
|
||||
self, room_ids: Collection[str], search_term: str, keys: Iterable[str]
|
||||
) -> JsonDict:
|
||||
"""Performs a full text search over events with given keys.
|
||||
|
||||
Args:
|
||||
room_ids (list): List of room ids to search in
|
||||
search_term (str): Search term to search for
|
||||
keys (list): List of keys to search in, currently supports
|
||||
room_ids: List of room ids to search in
|
||||
search_term: Search term to search for
|
||||
keys: List of keys to search in, currently supports
|
||||
"content.body", "content.name", "content.topic"
|
||||
|
||||
Returns:
|
||||
list of dicts
|
||||
Dictionary of results
|
||||
"""
|
||||
clauses = []
|
||||
|
||||
|
@ -499,10 +502,10 @@ class SearchStore(SearchBackgroundUpdateStore):
|
|||
self,
|
||||
room_ids: Collection[str],
|
||||
search_term: str,
|
||||
keys: List[str],
|
||||
keys: Iterable[str],
|
||||
limit,
|
||||
pagination_token: Optional[str] = None,
|
||||
) -> List[dict]:
|
||||
) -> JsonDict:
|
||||
"""Performs a full text search over events with given keys.
|
||||
|
||||
Args:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue