be fe fixes
This commit is contained in:
@@ -102,13 +102,14 @@ class ClusterSerializer(serializers.ModelSerializer):
|
||||
return ContentIdeas.objects.filter(keyword_cluster_id=obj.id).count()
|
||||
|
||||
def get_content_count(self, obj):
|
||||
"""Count generated content items linked to this cluster via tasks"""
|
||||
"""Count generated content items linked to this cluster"""
|
||||
if hasattr(obj, '_content_count'):
|
||||
return obj._content_count
|
||||
|
||||
from igny8_core.modules.writer.models import Content
|
||||
|
||||
return Content.objects.filter(task__cluster_id=obj.id).count()
|
||||
# Content links directly to clusters now (task field was removed in refactor)
|
||||
return Content.objects.filter(cluster_id=obj.id).count()
|
||||
|
||||
@classmethod
|
||||
def prefetch_keyword_stats(cls, clusters):
|
||||
@@ -166,16 +167,16 @@ class ClusterSerializer(serializers.ModelSerializer):
|
||||
)
|
||||
idea_stats = {item['keyword_cluster_id']: item['count'] for item in idea_counts}
|
||||
|
||||
# Prefetch content counts (through writer.Tasks -> Content)
|
||||
# Prefetch content counts (Content links directly to Clusters now)
|
||||
from igny8_core.modules.writer.models import Content
|
||||
|
||||
content_counts = (
|
||||
Content.objects
|
||||
.filter(task__cluster_id__in=cluster_ids)
|
||||
.values('task__cluster_id')
|
||||
.filter(cluster_id__in=cluster_ids)
|
||||
.values('cluster_id')
|
||||
.annotate(count=Count('id'))
|
||||
)
|
||||
content_stats = {item['task__cluster_id']: item['count'] for item in content_counts}
|
||||
content_stats = {item['cluster_id']: item['count'] for item in content_counts}
|
||||
|
||||
# Attach stats to each cluster object
|
||||
for cluster in clusters:
|
||||
|
||||
Reference in New Issue
Block a user