diff --git a/marietje/api/views.py b/marietje/api/views.py index 2e1fb42..fe25e86 100644 --- a/marietje/api/views.py +++ b/marietje/api/views.py @@ -314,7 +314,7 @@ def mute(request): @transaction.atomic def upload_stats(user): - q = PlaylistSong.objects.filter(user=user, song__deleted=False).aggregate( + q = PlaylistSong.objects.filter(user=user, state=2, song__deleted=False).aggregate( minutes_queued=Coalesce(Sum('song__duration'), Value(0))) q.update(Song.objects.filter(user=user, deleted=False).aggregate( minutes_upload=Coalesce(Sum('duration'), Value(0)))) diff --git a/marietje/queues/models.py b/marietje/queues/models.py index 9f8c5db..0aeaa73 100644 --- a/marietje/queues/models.py +++ b/marietje/queues/models.py @@ -15,19 +15,20 @@ class PlaylistSong(models.Model): Playlist, on_delete=models.SET_NULL, blank=True, - null=True + null=True, ) song = models.ForeignKey( Song, on_delete=models.SET_NULL, blank=True, - null=True + null=True, ) user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.SET_NULL, blank=True, - null=True + null=True, + db_index=True, ) played_at = models.DateTimeField(blank=True, null=True)