Skip to content

Commit 93f436d

Browse files
committed
fix: circuvent meilisearch bug with empty objects
1 parent eb7d2d1 commit 93f436d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: openedx/core/djangoapps/content/search/documents.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ def _collections_for_content_object(object_id: UsageKey | LearningContextKey) ->
267267
}
268268
269269
"""
270+
result = {
271+
Fields.collections: {
272+
Fields.collections_display_name: [],
273+
Fields.collections_key: [],
274+
}
275+
}
276+
270277
# Gather the collections associated with this object
271278
collections = None
272279
try:
@@ -279,14 +286,8 @@ def _collections_for_content_object(object_id: UsageKey | LearningContextKey) ->
279286
log.warning(f"No component found for {object_id}")
280287

281288
if not collections:
282-
return {Fields.collections: {}}
289+
return result
283290

284-
result = {
285-
Fields.collections: {
286-
Fields.collections_display_name: [],
287-
Fields.collections_key: [],
288-
}
289-
}
290291
for collection in collections:
291292
result[Fields.collections][Fields.collections_display_name].append(collection.title)
292293
result[Fields.collections][Fields.collections_key].append(collection.key)

0 commit comments

Comments
 (0)