From 8fe50a7e3678c9bc27b1178935c77e9413451a51 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Tue, 17 Sep 2024 12:37:02 -0700 Subject: [PATCH] feat: when changing a v2 library block, update search index synchronously --- openedx/core/djangoapps/content/search/handlers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/content/search/handlers.py b/openedx/core/djangoapps/content/search/handlers.py index 1605f8ebfd58..43e6d2912935 100644 --- a/openedx/core/djangoapps/content/search/handlers.py +++ b/openedx/core/djangoapps/content/search/handlers.py @@ -124,7 +124,9 @@ def library_block_updated_handler(**kwargs) -> None: log.error("Received null or incorrect data for event") return - upsert_library_block_index_doc.delay(str(library_block_data.usage_key)) + # Update content library index synchronously to make sure that search index is updated before + # the frontend invalidates/refetches results. This is only a single document update so is very fast. + upsert_library_block_index_doc.apply(args=[str(library_block_data.usage_key)]) @receiver(LIBRARY_BLOCK_DELETED)