diff --git a/app/torrent/consumers.py b/app/torrent/consumers.py index 75d72ae..9c54e5f 100644 --- a/app/torrent/consumers.py +++ b/app/torrent/consumers.py @@ -41,7 +41,6 @@ class TorrentEventConsumer(AsyncJsonWebsocketConsumer): await self.channel_layer.group_discard("torrent", self.channel_name) async def dispatch(self, message): - print("dispatch ws :", message) return await super().dispatch(message) async def receive_json(self, content, **kwargs): diff --git a/app/user/views.py b/app/user/views.py index 59938b8..a766a91 100644 --- a/app/user/views.py +++ b/app/user/views.py @@ -3,6 +3,7 @@ from django.views.generic import CreateView from django.contrib.auth import login from django.urls import reverse_lazy from django.db.models import Count, Sum, F, IntegerField +from django.db.models.functions import Coalesce from rest_framework.viewsets import ModelViewSet, GenericViewSet from rest_framework import mixins @@ -96,9 +97,9 @@ class UserViewSet(mixins.RetrieveModelMixin, @action(methods=["get"], detail=False) def user_stats(self, request): stats = User.objects.filter(id=request.user.id).aggregate( - total_size=Sum("torrents__size"), - total_torrent=Count("torrents"), - total_shared_torrent=Count("torrents_shares", distinct=True), + total_size=Coalesce(Sum("torrents__size"), 0), + total_torrent=Coalesce(Count("torrents"), 0), + total_shared_torrent=Coalesce(Count("torrents_shares", distinct=True), 0), ) disk_usage = shutil.disk_usage("/")