From 2c6c8cf9d98ff28a60c2f928115544e6906e296b Mon Sep 17 00:00:00 2001 From: Jillian Vogel Date: Thu, 12 Sep 2024 15:39:13 +0930 Subject: [PATCH] fix: apply library collection changes synchronously to update the index before the frontend re-fetches --- openedx/core/djangoapps/content/search/handlers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openedx/core/djangoapps/content/search/handlers.py b/openedx/core/djangoapps/content/search/handlers.py index b41c0e5d7851..6a341c92ed2b 100644 --- a/openedx/core/djangoapps/content/search/handlers.py +++ b/openedx/core/djangoapps/content/search/handlers.py @@ -167,10 +167,13 @@ def library_collection_updated_handler(**kwargs) -> None: log.error("Received null or incorrect data for event") return - update_library_collection_index_doc.delay( + # Update collection index synchronously to make sure that search index is updated before + # the frontend invalidates/refetches index. + # See content_library_updated_handler for more details. + update_library_collection_index_doc.apply(args=[ str(library_collection.library_key), library_collection.collection_key, - ) + ]) @receiver(CONTENT_OBJECT_ASSOCIATIONS_CHANGED)