From 25baeca2b042696a8057e214247c17c08cd8d4e3 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Wed, 27 May 2026 14:10:37 -0400 Subject: [PATCH] [calendar] Add fun to calendar day links --- vrobbler/apps/scrobbles/views.py | 15 +++++++++++++++ vrobbler/templates/scrobbles/calendar.html | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index 2eeed05..4b6b593 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -1368,6 +1368,20 @@ class ScrobbleCalendarView(LoginRequiredMixin, TemplateView): .order_by("timestamp") ) + from django.db.models import Count + from django.db.models.functions import TruncDate + total_by_day = dict( + Scrobble.objects.filter( + user=self.request.user, + timestamp__date__gte=month_start, + timestamp__date__lte=month_end, + ) + .annotate(local_date=TruncDate("timestamp", tzinfo=timezone.get_current_timezone())) + .values("local_date") + .annotate(count=Count("id")) + .values_list("local_date", "count") + ) + day_map = {d: [] for d in range(1, total_days + 1)} for scrobble in scrobbles: local_ts = timezone.localtime(scrobble.timestamp) @@ -1395,6 +1409,7 @@ class ScrobbleCalendarView(LoginRequiredMixin, TemplateView): calendar_days.append({ "day": day_num, "scrobbles": day_scrobbles, + "total_count": total_by_day.get(datetime(year, month, day_num).date(), 0), "is_today": year == today.year and month == today.month and day_num == today.day, "color": self._day_color(month, day_num, total_days), }) diff --git a/vrobbler/templates/scrobbles/calendar.html b/vrobbler/templates/scrobbles/calendar.html index 7dc8c07..0eb756d 100644 --- a/vrobbler/templates/scrobbles/calendar.html +++ b/vrobbler/templates/scrobbles/calendar.html @@ -191,7 +191,7 @@ header.navbar { display: none !important; } {% for cd in calendar_days %}
-
{{ cd.day }}
+
{{ cd.day }}{% if cd.total_count > 0 %} {{ cd.total_count }}{% endif %}
{% for s in cd.scrobbles %}