Fix filter order with annotations
We were getting all artists of all time, not just for the time period
This commit is contained in:
@ -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)
|
time_filter = Q(scrobble__timestamp__gte=STARTING_DAY_OF_CURRENT_YEAR)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
Track.objects.annotate(num_scrobbles=Count("scrobble", distinct=True))
|
Track.objects.filter(time_filter)
|
||||||
.filter(time_filter)
|
.annotate(num_scrobbles=Count("scrobble", distinct=True))
|
||||||
.order_by("-num_scrobbles")[:limit]
|
.order_by("-num_scrobbles")[:limit]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -93,10 +93,8 @@ def top_artists(filter: str = "today", limit: int = 15) -> List["Artist"]:
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
Artist.objects.annotate(
|
Artist.objects.filter(time_filter)
|
||||||
num_scrobbles=Count("track__scrobble", distinct=True)
|
.annotate(num_scrobbles=Count("track__scrobble", distinct=True))
|
||||||
)
|
|
||||||
.filter(time_filter)
|
|
||||||
.order_by("-num_scrobbles")[:limit]
|
.order_by("-num_scrobbles")[:limit]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,2 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
JELLYFIN_VIDEO_ITEM_TYPES = ["Episode", "Movie"]
|
JELLYFIN_VIDEO_ITEM_TYPES = ["Episode", "Movie"]
|
||||||
JELLYFIN_AUDIO_ITEM_TYPES = ["Audio"]
|
JELLYFIN_AUDIO_ITEM_TYPES = ["Audio"]
|
||||||
|
|||||||
@ -39,18 +39,6 @@ from vrobbler.apps.music.aggregators import (
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
TRUTHY_VALUES = [
|
|
||||||
'true',
|
|
||||||
'1',
|
|
||||||
't',
|
|
||||||
'y',
|
|
||||||
'yes',
|
|
||||||
'yeah',
|
|
||||||
'yup',
|
|
||||||
'certainly',
|
|
||||||
'uh-huh',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class RecentScrobbleList(ListView):
|
class RecentScrobbleList(ListView):
|
||||||
model = Scrobble
|
model = Scrobble
|
||||||
|
|||||||
Reference in New Issue
Block a user