From c62588c359da4e3271569c27220611f064eb2049 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 7 Nov 2017 07:18:42 -0800 Subject: [PATCH] minor: Use dict comprehension in get_messages_backend(). --- zerver/views/messages.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zerver/views/messages.py b/zerver/views/messages.py index 7b13b2633b..388ba96ca7 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -735,9 +735,10 @@ def get_messages_backend(request, user_profile, message_ids = [row[0] for row in query_result] # TODO: This could be done with an outer join instead of two queries - user_message_flags = dict((user_message.message_id, user_message.flags_list()) for user_message in - UserMessage.objects.filter(user_profile=user_profile, - message__id__in=message_ids)) + um_rows = UserMessage.objects.filter(user_profile=user_profile, + message__id__in=message_ids) + user_message_flags = {um.message_id: um.flags_list() for um in um_rows} + for row in query_result: message_id = row[0] if user_message_flags.get(message_id) is None: