From 934535fea58306a5f3be6106512ff874fccef550 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 11 Sep 2018 15:30:32 +0100 Subject: [PATCH] improve hero ordering --- synapse/storage/roommember.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py index 002e3ec681..0707f9a86a 100644 --- a/synapse/storage/roommember.py +++ b/synapse/storage/roommember.py @@ -118,6 +118,8 @@ class RoomMemberWorkerStore(EventsWorkerStore): for count, membership in txn: summary = res.setdefault(to_ascii(membership), MemberSummary([], count)) + # we order by membership and then fairly arbitrarily by event_id so + # heroes are consistent sql = """ SELECT m.user_id, m.membership, m.event_id FROM room_memberships as m @@ -126,7 +128,9 @@ class RoomMemberWorkerStore(EventsWorkerStore): AND m.room_id = c.room_id AND m.user_id = c.state_key WHERE c.type = 'm.room.member' AND c.room_id = ? - ORDER BY CASE m.membership WHEN ? THEN 1 WHEN ? THEN 2 ELSE 3 END ASC + ORDER BY + CASE m.membership WHEN ? THEN 1 WHEN ? THEN 2 ELSE 3 END ASC, + m.event_id ASC LIMIT ? """