Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
topic: Reorder topic history functions.
Tim Abbott3b2a262b6f91
diff --git a/zerver/lib/topic.py b/zerver/lib/topic.pyindex a79b74af006..f6518118d6e 100644--- a/zerver/lib/topic.py+++ b/zerver/lib/topic.py@@ -158,23 +158,14 @@ def generate_topic_history_from_db_rows(rows: List[Tuple[str, int]]) -> List[Dic)return sorted(history, key=lambda x: -x['max_id'])-def get_topic_history_for_stream(user_profile: UserProfile,- recipient: Recipient,- public_history: bool) -> List[Dict[str, Any]]:- if public_history:- return get_topic_history_for_public_stream(recipient)-+def get_topic_history_for_public_stream(recipient: Recipient) -> List[Dict[str, Any]]:cursor = connection.cursor()query = '''SELECT"zerver_message"."subject" as topic,max("zerver_message".id) as max_message_idFROM "zerver_message"- INNER JOIN "zerver_usermessage" ON (- "zerver_usermessage"."message_id" = "zerver_message"."id"- )WHERE (- "zerver_usermessage"."user_profile_id" = %s AND"zerver_message"."recipient_id" = %s)GROUP BY (@@ -182,20 +173,29 @@ def get_topic_history_for_stream(user_profile: UserProfile,)ORDER BY max("zerver_message".id) DESC'''- cursor.execute(query, [user_profile.id, recipient.id])+ cursor.execute(query, [recipient.id])rows = cursor.fetchall()cursor.close()return generate_topic_history_from_db_rows(rows)-def get_topic_history_for_public_stream(recipient: Recipient) -> List[Dict[str, Any]]:+def get_topic_history_for_stream(user_profile: UserProfile,+ recipient: Recipient,+ public_history: bool) -> List[Dict[str, Any]]:+ if public_history:+ return get_topic_history_for_public_stream(recipient)+cursor = connection.cursor()query = '''SELECT"zerver_message"."subject" as topic,max("zerver_message".id) as max_message_idFROM "zerver_message"+ INNER JOIN "zerver_usermessage" ON (+ "zerver_usermessage"."message_id" = "zerver_message"."id"+ )WHERE (+ "zerver_usermessage"."user_profile_id" = %s AND"zerver_message"."recipient_id" = %s)GROUP BY (@@ -203,7 +203,7 @@ def get_topic_history_for_public_stream(recipient: Recipient) -> List[Dict[str,)ORDER BY max("zerver_message".id) DESC'''- cursor.execute(query, [recipient.id])+ cursor.execute(query, [user_profile.id, recipient.id])rows = cursor.fetchall()cursor.close()