Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Inline the where clause.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Mar 24, 2022
1 parent 49c9d89 commit 884329e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions synapse/storage/databases/main/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 884329e

Please sign in to comment.