From 2e3cccd6922af2cea70ad7b1887b2407c849a93b Mon Sep 17 00:00:00 2001 From: Navin Karkera Date: Thu, 12 Dec 2024 12:12:48 +0530 Subject: [PATCH] fix: include collection data on indexing new library blocks --- openedx/core/djangoapps/content/search/documents.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/content/search/documents.py b/openedx/core/djangoapps/content/search/documents.py index 0dd02683ceea..245d9db8af12 100644 --- a/openedx/core/djangoapps/content/search/documents.py +++ b/openedx/core/djangoapps/content/search/documents.py @@ -306,7 +306,10 @@ def _collections_for_content_object(object_id: UsageKey | LearningContextKey) -> If the object is in no collections, returns: { - "collections": {}, + "collections": { + "display_name": [], + "key": [], + }, } """ @@ -398,6 +401,8 @@ def searchable_doc_for_library_block(xblock_metadata: lib_api.LibraryXBlockMetad # Add the breadcrumbs. In v2 libraries, the library itself is not a "parent" of the XBlocks so we add it here: doc[Fields.breadcrumbs] = [{"display_name": library_name}] + # Add collections data to index if this block is part of any collection + doc.update(_collections_for_content_object(xblock_metadata.usage_key)) return doc