mirror of https://github.com/zulip/zulip.git
refactor: Use list of topics, not tuples.
This commit is contained in:
parent
878e938a89
commit
6ac3cd3534
|
@ -117,18 +117,18 @@ def gather_hot_conversations(
|
||||||
conversation_senders[key].add(message.sender.full_name)
|
conversation_senders[key].add(message.sender.full_name)
|
||||||
conversation_length[key] += 1
|
conversation_length[key] += 1
|
||||||
|
|
||||||
diversity_list = list(conversation_senders.items())
|
topics_by_diversity = list(conversation_senders)
|
||||||
diversity_list.sort(key=lambda entry: len(entry[1]), reverse=True)
|
topics_by_diversity.sort(key=lambda key: conversation_senders[key], reverse=True)
|
||||||
|
|
||||||
length_list = list(conversation_length.items())
|
topics_by_length = list(conversation_length)
|
||||||
length_list.sort(key=lambda entry: entry[1], reverse=True)
|
topics_by_diversity.sort(key=lambda key: conversation_length[key], reverse=True)
|
||||||
|
|
||||||
# Get up to the 4 best conversations from the diversity list
|
# Get up to the 4 best conversations from the diversity list
|
||||||
# and length list, filtering out overlapping conversations.
|
# and length list, filtering out overlapping conversations.
|
||||||
hot_conversations = [elt[0] for elt in diversity_list[:2]]
|
hot_conversations = topics_by_diversity[:2]
|
||||||
for candidate, _ in length_list:
|
for topic_key in topics_by_length:
|
||||||
if candidate not in hot_conversations:
|
if topic_key not in hot_conversations:
|
||||||
hot_conversations.append(candidate)
|
hot_conversations.append(topic_key)
|
||||||
if len(hot_conversations) >= 4:
|
if len(hot_conversations) >= 4:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ def gather_hot_conversations(
|
||||||
# out the hot conversations.
|
# out the hot conversations.
|
||||||
num_convos = len(hot_conversations)
|
num_convos = len(hot_conversations)
|
||||||
if num_convos < 4:
|
if num_convos < 4:
|
||||||
hot_conversations.extend(elt[0] for elt in diversity_list[num_convos:4])
|
hot_conversations.extend(topics_by_diversity[num_convos:4])
|
||||||
|
|
||||||
hot_conversation_render_payloads = []
|
hot_conversation_render_payloads = []
|
||||||
for h in hot_conversations:
|
for h in hot_conversations:
|
||||||
|
|
Loading…
Reference in New Issue