Skip to content

Commit

Permalink
fix: Add tags count to library block metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisChV committed Sep 20, 2024
1 parent cf3673e commit 72fbf10
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions openedx/core/djangoapps/content_libraries/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,13 @@ def from_component(cls, library_key, component):
last_draft_created = draft.created if draft else None
last_draft_created_by = draft.publishable_entity_version.created_by if draft else None

# Build 'lib:' component usage_key from component slug and library_key
component_key = str(component).replace('xblock.v1:', f'{str(library_key)}:').replace('lib:', 'lb:')
components_tags = _get_library_component_tags_count(library_key)
tags_count = 0
if component_key in components_tags:
tags_count = components_tags[component_key]

return cls(
usage_key=LibraryUsageLocatorV2(
library_key,
Expand All @@ -255,6 +262,7 @@ def from_component(cls, library_key, component):
last_draft_created=last_draft_created,
last_draft_created_by=last_draft_created_by,
has_unpublished_changes=component.versioning.has_unpublished_changes,
tags_count=tags_count
)


Expand Down

0 comments on commit 72fbf10

Please sign in to comment.