Skip to content

Commit

Permalink
Merge pull request #6494 from akatsoulas/dup-docs-per-topic
Browse files Browse the repository at this point in the history
Remove duplicate docs per topic
  • Loading branch information
akatsoulas authored Feb 6, 2025
2 parents c1573f6 + e625a79 commit 73b952d
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kitsune/wiki/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,16 @@ def build_topics_data(request: HttpRequest, product: Product, topics: list[Topic
doc_topics_map: dict[int, list[Topic]] = {}

for doc in all_documents:
doc_topics = list(doc.topics.all()) or (
list(doc.parent.topics.all()) if doc.parent else []
doc_topics = set(doc.topics.all()) or (
set(doc.parent.topics.all()) if doc.parent else set()
)

doc_topics_map[doc.id] = doc_topics
doc_topics_map[doc.id] = list(doc_topics)
for topic in doc_topics:
if topic.id in topic_docs_map:
main_list, fallback_list = topic_docs_map[topic.id]
target_list = main_list if doc.id in main_doc_ids else fallback_list
if doc not in target_list:
target_list.append(doc)
target_list.append(doc)

for topic in topics:
main_topic_docs, fallback_topic_docs = topic_docs_map[topic.id]
Expand Down

0 comments on commit 73b952d

Please sign in to comment.