@@ -210,12 +210,16 @@ class LibraryXBlockMetadata(PublishableItem):
210210 Class that represents the metadata about an XBlock in a content library.
211211 """
212212 usage_key : LibraryUsageLocatorV2
213+ tags_count : int = 0
213214
214215 @classmethod
215216 def from_component (cls , library_key , component , associated_collections = None ):
216217 """
217218 Construct a LibraryXBlockMetadata from a Component object.
218219 """
220+ # Import content_tagging.api here to avoid circular imports
221+ from openedx .core .djangoapps .content_tagging .api import get_object_tag_counts
222+
219223 last_publish_log = component .versioning .last_publish_log
220224
221225 published_by = None
@@ -226,12 +230,11 @@ def from_component(cls, library_key, component, associated_collections=None):
226230 published = component .versioning .published
227231 last_draft_created = draft .created if draft else None
228232 last_draft_created_by = draft .publishable_entity_version .created_by if draft else None
233+ usage_key = library_component_usage_key (library_key , component )
234+ tags = get_object_tag_counts (str (usage_key ), count_implicit = True )
229235
230236 return cls (
231- usage_key = library_component_usage_key (
232- library_key ,
233- component ,
234- ),
237+ usage_key = usage_key ,
235238 display_name = draft .title ,
236239 created = component .created ,
237240 modified = draft .created ,
@@ -244,6 +247,7 @@ def from_component(cls, library_key, component, associated_collections=None):
244247 has_unpublished_changes = component .versioning .has_unpublished_changes ,
245248 collections = associated_collections or [],
246249 can_stand_alone = component .publishable_entity .can_stand_alone ,
250+ tags_count = tags .get (str (usage_key ), 0 ),
247251 )
248252
249253
0 commit comments