浏览代码

Fix filter order with annotations

We were getting all artists of all time, not just for the time period
Colin Powell 2 年之前
父节点
当前提交
d700b581a1
共有 3 个文件被更改,包括 4 次插入19 次删除
  1. 4 6
      vrobbler/apps/music/aggregators.py
  2. 0 1
      vrobbler/apps/scrobbles/constants.py
  3. 0 12
      vrobbler/apps/scrobbles/views.py

+ 4 - 6
vrobbler/apps/music/aggregators.py

@@ -71,8 +71,8 @@ def top_tracks(filter: str = "today", limit: int = 15) -> List["Track"]:
         time_filter = Q(scrobble__timestamp__gte=STARTING_DAY_OF_CURRENT_YEAR)
 
     return (
-        Track.objects.annotate(num_scrobbles=Count("scrobble", distinct=True))
-        .filter(time_filter)
+        Track.objects.filter(time_filter)
+        .annotate(num_scrobbles=Count("scrobble", distinct=True))
         .order_by("-num_scrobbles")[:limit]
     )
 
@@ -93,10 +93,8 @@ def top_artists(filter: str = "today", limit: int = 15) -> List["Artist"]:
         )
 
     return (
-        Artist.objects.annotate(
-            num_scrobbles=Count("track__scrobble", distinct=True)
-        )
-        .filter(time_filter)
+        Artist.objects.filter(time_filter)
+        .annotate(num_scrobbles=Count("track__scrobble", distinct=True))
         .order_by("-num_scrobbles")[:limit]
     )
 

+ 0 - 1
vrobbler/apps/scrobbles/constants.py

@@ -1,3 +1,2 @@
-#!/usr/bin/env python3
 JELLYFIN_VIDEO_ITEM_TYPES = ["Episode", "Movie"]
 JELLYFIN_AUDIO_ITEM_TYPES = ["Audio"]

+ 0 - 12
vrobbler/apps/scrobbles/views.py

@@ -39,18 +39,6 @@ from vrobbler.apps.music.aggregators import (
 
 logger = logging.getLogger(__name__)
 
-TRUTHY_VALUES = [
-    'true',
-    '1',
-    't',
-    'y',
-    'yes',
-    'yeah',
-    'yup',
-    'certainly',
-    'uh-huh',
-]
-
 
 class RecentScrobbleList(ListView):
     model = Scrobble