[podcasts] Add aggregation to templates
All checks were successful
build & deploy / test (push) Successful in 1m40s
build & deploy / deploy (push) Successful in 20s

This commit is contained in:
2026-03-18 11:07:45 -04:00
parent 28db747b59
commit 8e8d25aa1d
3 changed files with 13 additions and 32 deletions

View File

@ -1,15 +1,15 @@
import datetime
from django.utils import timezone
from django.views import generic
from podcasts.models import Podcast
from podcasts.models import Podcast, PodcastEpisode
from scrobbles.models import Scrobble
from scrobbles.views import ScrobbleableListView, ScrobbleableDetailView
class PodcastListView(generic.ListView):
model = Podcast
paginate_by = 20
class PodcastListView(ScrobbleableListView):
model = PodcastEpisode
template_name = "podcasts/podcast_list.html"
def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
@ -36,10 +36,7 @@ class PodcastListView(generic.ListView):
if podcast:
podcasts_this_week[podcast.id] = {
"podcast": podcast,
"count": podcasts_this_week.get(podcast.id, {}).get(
"count", 0
)
+ 1,
"count": podcasts_this_week.get(podcast.id, {}).get("count", 0) + 1,
}
podcasts_this_month = {}
@ -48,9 +45,7 @@ class PodcastListView(generic.ListView):
if podcast:
podcasts_this_month[podcast.id] = {
"podcast": podcast,
"count": podcasts_this_month.get(podcast.id, {}).get(
"count", 0
)
"count": podcasts_this_month.get(podcast.id, {}).get("count", 0)
+ 1,
}