Skip to content

Commit

Permalink
feat: implicitCount added to content serach index
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Jun 17, 2024
1 parent 68b3a38 commit ee5b26f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions openedx/core/djangoapps/content/search/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Fields:
# For details on the format of the hierarchical tag data.
# We currently have a hard-coded limit of 4 levels of tags in the search index (level0..level3).
tags = "tags"
tags_count = "implicit_count"
tags_taxonomy = "taxonomy" # subfield of tags, i.e. tags.taxonomy
tags_level0 = "level0" # subfield of tags, i.e. tags.level0
tags_level1 = "level1"
Expand Down Expand Up @@ -183,9 +184,14 @@ def _tags_for_content_object(object_id: UsageKey | LearningContextKey) -> dict:
# Clear out tags in the index when unselecting all tags for the block, otherwise
# it would remain the last value if a cleared Fields.tags field is not included
return {Fields.tags: {}}
tags_count = tagging_api.get_object_tag_counts(str(object_id), count_implicit=True)
tag_count = 0
if str(object_id) in tags_count:
tag_count = tags_count[str(object_id)]
result = {
Fields.tags_taxonomy: [],
Fields.tags_level0: [],
Fields.tags_count: tag_count,
# ... other levels added as needed
}
for obj_tag in all_tags:
Expand Down

0 comments on commit ee5b26f

Please sign in to comment.