Skip to content

Commit

Permalink
fix: update library v2 search index synchronously (#35367)
Browse files Browse the repository at this point in the history
Discarded components need to be removed from index in sync to make sure
that users see the latest updated data.
  • Loading branch information
navinkarkera authored Aug 30, 2024
1 parent bfee53b commit ec34753
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion openedx/core/djangoapps/content/search/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ def content_library_updated_handler(**kwargs) -> None:
log.error("Received null or incorrect data for event")
return

update_content_library_index_docs.delay(str(content_library_data.library_key))
# Update content library index synchronously to make sure that search index is updated before
# the frontend invalidates/refetches index.
# Currently, this is only required to make sure that removed/discarded components are removed
# from the search index and displayed to user properly. If it becomes a performance bottleneck
# for other update operations other than discard, we can update CONTENT_LIBRARY_UPDATED event
# to include a parameter which can help us decide if the task needs to run sync or async.
update_content_library_index_docs.apply(args=[str(content_library_data.library_key)])


@receiver(CONTENT_OBJECT_TAGS_CHANGED)
Expand Down

0 comments on commit ec34753

Please sign in to comment.