[charts] Clean up how they're displayed
All checks were successful
build & deploy / test (push) Successful in 1m51s
build & deploy / build-and-deploy (push) Successful in 30s

This commit is contained in:
2026-05-15 16:03:53 -04:00
parent 2b04a17d77
commit bf7e5677e6
8 changed files with 217 additions and 22 deletions

View File

@ -14,13 +14,6 @@ class TrackListView(ScrobbleableListView):
class TrackDetailView(ScrobbleableDetailView):
model = Track
def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
context_data["charts"] = ChartRecord.objects.filter(
track=self.object, rank__in=[1, 2, 3]
)
return context_data
class ArtistListView(generic.ListView):
model = Artist
@ -57,9 +50,16 @@ class ArtistDetailView(generic.DetailView):
]
context_data["tracks_ranked"] = tracks_ranked
context_data["charts"] = ChartRecord.objects.filter(
charts_qs = ChartRecord.objects.filter(
artist=self.object, rank__in=[1, 2, 3]
)
).exclude(day__isnull=False)
from collections import OrderedDict
grouped = OrderedDict()
for chart in charts_qs:
grouped.setdefault(chart.period_type, []).append(chart)
context_data["charts"] = grouped
from scrobbles.models import Scrobble