[scrobbles] Fix filtering by tags
All checks were successful
build & deploy / test (push) Successful in 1m47s
build & deploy / deploy (push) Successful in 22s

This commit is contained in:
2026-04-02 12:23:05 -04:00
parent 29e179adad
commit 3b266083b0
3 changed files with 29 additions and 27 deletions

View File

@ -192,26 +192,6 @@ class ScrobbleableDetailView(ChartContextMixin, DetailView):
class RecentScrobbleList(ListView):
model = Scrobble
class ScrobbleListView(LoginRequiredMixin, ListView):
model = Scrobble
paginate_by = 100
template_name = "scrobbles/scrobble_all_list.html"
def get_queryset(self):
qs = Scrobble.objects.filter(user=self.request.user).order_by("-timestamp")
tags_param = self.request.GET.get("tags", "")
if tags_param:
tag_list = [t.strip() for t in tags_param.split(",") if t.strip()]
if tag_list:
qs = qs.filter(tags__name__in=tag_list).distinct()
return qs
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx["tags_param"] = self.request.GET.get("tags", "")
return ctx
def get(self, *args, **kwargs):
user = self.request.user
if user.is_authenticated:
@ -324,6 +304,26 @@ class ScrobbleListView(LoginRequiredMixin, ListView):
return Scrobble.objects.all().order_by("-timestamp")
class ScrobbleListView(LoginRequiredMixin, ListView):
model = Scrobble
paginate_by = 100
template_name = "scrobbles/scrobble_all_list.html"
def get_queryset(self):
qs = Scrobble.objects.filter(user=self.request.user).order_by("-timestamp")
tags_param = self.request.GET.get("tags", "")
if tags_param:
tag_list = [t.strip() for t in tags_param.split(",") if t.strip()]
if tag_list:
qs = qs.filter(tags__name__in=tag_list).distinct()
return qs
def get_context_data(self, **kwargs):
ctx = super().get_context_data(**kwargs)
ctx["tags_param"] = self.request.GET.get("tags", "")
return ctx
class ScrobbleLongPlaysView(TemplateView):
template_name = "scrobbles/long_plays_in_progress.html"