Skip to content

Commit a23aa81

Browse files
committed
Fix ChannelFileSummaryViewSet becasuse no middleware?
1 parent 3082a88 commit a23aa81

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

kolibri/content/api.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.db.models import Q, Sum
88
from django.db.models.aggregates import Count
99
from kolibri.content import models, serializers
10-
from kolibri.content.content_db_router import get_active_content_database
10+
from kolibri.content.content_db_router import get_active_content_database, using_content_database
1111
from kolibri.logger.models import ContentSessionLog, ContentSummaryLog
1212
from le_utils.constants import content_kinds
1313
from rest_framework import filters, pagination, viewsets
@@ -359,10 +359,11 @@ def get_queryset(self):
359359

360360
class ChannelFileSummaryViewSet(viewsets.ViewSet):
361361
def list(self, request, **kwargs):
362-
file_summary = models.File.objects.aggregate(
363-
total_files=Count('pk'),
364-
total_file_size=Sum('file_size')
365-
)
366-
file_summary['channel_id'] = get_active_content_database()
367-
# Need to wrap in an array to be fetchable as a Collection on client
368-
return Response([file_summary])
362+
with using_content_database(kwargs['channel_id']):
363+
file_summary = models.File.objects.aggregate(
364+
total_files=Count('pk'),
365+
total_file_size=Sum('file_size')
366+
)
367+
file_summary['channel_id'] = get_active_content_database()
368+
# Need to wrap in an array to be fetchable as a Collection on client
369+
return Response([file_summary])

0 commit comments

Comments
 (0)