diff --git a/synapse/storage/databases/main/event_push_actions.py b/synapse/storage/databases/main/event_push_actions.py index 7c764dc77fc1..7ebe34f773ab 100644 --- a/synapse/storage/databases/main/event_push_actions.py +++ b/synapse/storage/databases/main/event_push_actions.py @@ -495,8 +495,6 @@ def _get_unread_counts_by_room_for_user_txn( ) args.extend([user_id, user_id]) - room_to_count: Dict[str, int] = defaultdict(int) - receipts_cte = f""" WITH all_receipts AS ( SELECT room_id, thread_id, MAX(event_stream_ordering) AS max_receipt_stream_ordering @@ -557,6 +555,7 @@ def _get_unread_counts_by_room_for_user_txn( txn.execute(sql, args) seen_thread_ids = set() + room_to_count: Dict[str, int] = defaultdict(int) for room_id, thread_id, notif_count in txn: room_to_count[room_id] += notif_count