Skip to content

Commit

Permalink
fix: use lazy field to control collection update task
Browse files Browse the repository at this point in the history
  • Loading branch information
navinkarkera committed Oct 10, 2024
1 parent cd9eec9 commit e23588b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 13 additions & 7 deletions openedx/core/djangoapps/content/search/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,13 +179,19 @@ def library_collection_updated_handler(**kwargs) -> None:
log.error("Received null or incorrect data for event")
return

# 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,
])
if library_collection.lazy:
update_library_collection_index_doc.delay(
str(library_collection.library_key),
library_collection.collection_key,
)
else:
# 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)
Expand Down
6 changes: 1 addition & 5 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,17 +1287,13 @@ def set_library_component_collections(
key__in=collection_keys
)

affected_collections = authoring_api.set_collections(
authoring_api.set_collections(
content_library.learning_package_id,
component,
collection_qs,
created_by=created_by,
)

from ..content.search.tasks import update_library_collection_index_doc
for collection in affected_collections:
update_library_collection_index_doc.delay(str(library_key), collection.key)

return component


Expand Down

0 comments on commit e23588b

Please sign in to comment.