From 46d9a84e96d3b7fa802b23d55b91537155320d8b Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Thu, 8 Sep 2022 21:36:03 +0100 Subject: [PATCH 1/2] Concurrently collect room unread counts for push badges --- synapse/push/push_tools.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/synapse/push/push_tools.py b/synapse/push/push_tools.py index 6661887d9f92..658bf373b7c9 100644 --- a/synapse/push/push_tools.py +++ b/synapse/push/push_tools.py @@ -17,6 +17,7 @@ from synapse.push.presentable_names import calculate_room_name, name_from_member_event from synapse.storage.controllers import StorageControllers from synapse.storage.databases.main import DataStore +from synapse.util.async_helpers import concurrently_execute async def get_badge_count(store: DataStore, user_id: str, group_by_room: bool) -> int: @@ -25,13 +26,19 @@ async def get_badge_count(store: DataStore, user_id: str, group_by_room: bool) - badge = len(invites) - for room_id in joins: - notifs = await ( - store.get_unread_event_push_actions_by_room_for_user( + room_notifs = [] + + async def get_room_unread_count(room_id: str) -> None: + room_notifs.append( + await store.get_unread_event_push_actions_by_room_for_user( room_id, user_id, ) ) + + await concurrently_execute(get_room_unread_count, joins, 10) + + for notifs in room_notifs: if notifs.notify_count == 0: continue From cfba9af7eef8da4df3ef2340f02a3a7be51e8b2e Mon Sep 17 00:00:00 2001 From: Nick Barrett Date: Fri, 9 Sep 2022 11:09:12 +0100 Subject: [PATCH 2/2] Add changelog file --- changelog.d/13765.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/13765.misc diff --git a/changelog.d/13765.misc b/changelog.d/13765.misc new file mode 100644 index 000000000000..fdda5cf3b6a3 --- /dev/null +++ b/changelog.d/13765.misc @@ -0,0 +1 @@ +Concurrently fetch room push actions when calculating badge counts. Contributed by Nick @ Beeper (@fizzadar).