Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

topic: Add comments calling out case-sensitive index usage.

Alex Vandiverd55240e5430a
diff --git a/zerver/lib/topic.py b/zerver/lib/topic.py
index fba2833e1ab..4801cbff9ed 100644
--- a/zerver/lib/topic.py
+++ b/zerver/lib/topic.py
@@ -226,6 +226,9 @@ def generate_topic_history_from_db_rows(rows: List[Tuple[str, int]]) -> List[Dic
def get_topic_history_for_public_stream(realm_id: int, recipient_id: int) -> List[Dict[str, Any]]:
cursor = connection.cursor()
+ # Uses index: zerver_message_realm_recipient_subject
+ # Note that this is *case-sensitive*, so that we can display the
+ # most recently-used case (in generate_topic_history_from_db_rows)
query = """
SELECT
"zerver_message"."subject" as topic,
@@ -254,6 +257,9 @@ def get_topic_history_for_stream(
return get_topic_history_for_public_stream(user_profile.realm_id, recipient_id)
cursor = connection.cursor()
+ # Uses index: zerver_message_realm_recipient_subject
+ # Note that this is *case-sensitive*, so that we can display the
+ # most recently-used case (in generate_topic_history_from_db_rows)
query = """
SELECT
"zerver_message"."subject" as topic,
diff --git a/zerver/models.py b/zerver/models.py
index 813554008c9..f91a4c337d1 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -3175,7 +3175,9 @@ class Message(AbstractMessage):
name="zerver_message_realm_recipient_upper_subject",
),
models.Index(
- # Only used by already_sent_mirrored_message_id
+ # Used by already_sent_mirrored_message_id, and when
+ # determining recent topics (we post-process to merge
+ # and show the most recent case)
"realm_id",
"recipient_id",
"subject",