From 884329e83570c1c08f7f5eaf2ea11350cf668892 Mon Sep 17 00:00:00 2001 From: Patrick Cloke Date: Thu, 24 Mar 2022 14:21:02 -0400 Subject: [PATCH] Inline the where clause. --- synapse/storage/databases/main/relations.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/synapse/storage/databases/main/relations.py b/synapse/storage/databases/main/relations.py index 1c4f7a8588f1..dc5d0a19c115 100644 --- a/synapse/storage/databases/main/relations.py +++ b/synapse/storage/databases/main/relations.py @@ -268,7 +268,6 @@ async def get_aggregation_groups_for_event( `type`, `key` and `count` fields. """ - where_clause = ["relates_to_id = ?", "room_id = ?", "relation_type = ?"] where_args: List[Union[str, int]] = [ event_id, room_id, @@ -279,13 +278,11 @@ async def get_aggregation_groups_for_event( SELECT type, aggregation_key, COUNT(DISTINCT sender), MAX(stream_ordering) FROM event_relations INNER JOIN events USING (event_id) - WHERE {where_clause} + WHERE relates_to_id = ? AND room_id = ? AND relation_type = ? GROUP BY relation_type, type, aggregation_key ORDER BY COUNT(*) DESC, MAX(stream_ordering) DESC LIMIT ? - """.format( - where_clause=" AND ".join(where_clause) - ) + """ def _get_aggregation_groups_for_event_txn( txn: LoggingTransaction,