Skip to content

Commit

Permalink
fix: merging changes from upstream PR
Browse files Browse the repository at this point in the history
  • Loading branch information
rpenido committed Mar 19, 2024
1 parent 282cc05 commit d426306
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions openedx/core/djangoapps/content/search/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def _get_meilisearch_client():
return _MEILI_CLIENT

# Connect to Meilisearch
if not settings.MEILISEARCH_URL:
raise RuntimeError("MEILISEARCH_URL is not set - search functionality disabled.")
if not settings.MEILISEARCH_ENABLED:
raise RuntimeError("MEILISEARCH_ENABLED is not set - search functionality disabled.")

_MEILI_CLIENT = meilisearch.Client(settings.MEILISEARCH_URL, settings.MEILISEARCH_API_KEY)
try:
Expand Down Expand Up @@ -252,8 +252,9 @@ def nop(_message):
doc = searchable_doc_for_library_block(metadata)
docs.append(doc)
num_blocks_done += 1
# Add all the docs in this library at once (usually faster than adding one at a time):
_wait_for_meili_task(client.index(temp_index_name).add_documents(docs))
if docs:
# Add all the docs in this library at once (usually faster than adding one at a time):
_wait_for_meili_task(client.index(temp_index_name).add_documents(docs))
num_contexts_done += 1

############## Courses ##############
Expand All @@ -272,8 +273,9 @@ def add_with_children(block):

_recurse_children(course, add_with_children)

# Add all the docs in this course at once (usually faster than adding one at a time):
_wait_for_meili_task(client.index(temp_index_name).add_documents(docs))
if docs:
# Add all the docs in this course at once (usually faster than adding one at a time):
_wait_for_meili_task(client.index(temp_index_name).add_documents(docs))
num_contexts_done += 1
num_blocks_done += len(docs)

Expand Down
2 changes: 1 addition & 1 deletion openedx/core/djangoapps/content/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class implementation returns only:
{"content": {"display_name": "..."}, "content_type": "..."}
"""
block_data = {
Fields.id: _meili_id_from_opaque_key(block.usage_key),
Fields.id: meili_id_from_opaque_key(block.usage_key),
Fields.usage_key: str(block.usage_key),
Fields.block_id: str(block.usage_key.block_id),
Fields.display_name: xblock_api.get_block_display_name(block),
Expand Down

0 comments on commit d426306

Please sign in to comment.