diff --git a/vrobbler/apps/music/aggregators.py b/vrobbler/apps/music/aggregators.py index 09f17be..65554c8 100644 --- a/vrobbler/apps/music/aggregators.py +++ b/vrobbler/apps/music/aggregators.py @@ -94,7 +94,7 @@ def top_artists(filter: str = "today", limit: int = 15) -> List["Artist"]: return ( Artist.objects.annotate( - num_scrobbles=Sum("track__scrobble", distinct=True) + num_scrobbles=Count("track__scrobble", distinct=True) ) .filter(time_filter) .order_by("-num_scrobbles")[:limit] diff --git a/vrobbler/apps/scrobbles/admin.py b/vrobbler/apps/scrobbles/admin.py index 3b43424..117e9e6 100644 --- a/vrobbler/apps/scrobbles/admin.py +++ b/vrobbler/apps/scrobbles/admin.py @@ -13,7 +13,7 @@ class ScrobbleAdmin(admin.ModelAdmin): "playback_position", "in_progress", ) - list_filter = ("in_progress", "source") + list_filter = ("in_progress", "source", "track__artist") ordering = ("-timestamp",) diff --git a/vrobbler/apps/scrobbles/views.py b/vrobbler/apps/scrobbles/views.py index a5e8dcb..fea66bb 100644 --- a/vrobbler/apps/scrobbles/views.py +++ b/vrobbler/apps/scrobbles/views.py @@ -23,6 +23,7 @@ from scrobbles.utils import convert_to_seconds from videos.models import Video from vrobbler.apps.music.aggregators import ( scrobble_counts, + top_artists, top_tracks, week_of_scrobbles, ) @@ -62,6 +63,11 @@ class RecentScrobbleList(ListView): data['top_daily_tracks'] = top_tracks() data['top_weekly_tracks'] = top_tracks(filter='week') data['top_monthly_tracks'] = top_tracks(filter='month') + + data['top_daily_artists'] = top_artists() + data['top_weekly_artists'] = top_artists(filter='week') + data['top_monthly_artists'] = top_artists(filter='month') + data["weekly_data"] = week_of_scrobbles() data['counts'] = scrobble_counts() return data diff --git a/vrobbler/templates/base.html b/vrobbler/templates/base.html index ea40008..87a9634 100644 --- a/vrobbler/templates/base.html +++ b/vrobbler/templates/base.html @@ -280,35 +280,35 @@ var myChart = new Chart(ctx, { type: 'line', data: { - labels: [ - {% for day in weekly_data.keys %} - "{{day}}"{% if not forloop.last %},{% endif %} - {% endfor %} - ], - datasets: [{ - data: [ - {% for count in weekly_data.values %} - {{count}}{% if not forloop.last %},{% endif %} - {% endfor %} - ], - lineTension: 0, - backgroundColor: 'transparent', - borderColor: '#007bff', - borderWidth: 4, - pointBackgroundColor: '#007bff' - }] + labels: [ + {% for day in weekly_data.keys %} + "{{day}}"{% if not forloop.last %},{% endif %} + {% endfor %} + ], + datasets: [{ + data: [ + {% for count in weekly_data.values %} + {{count}}{% if not forloop.last %},{% endif %} + {% endfor %} + ], + lineTension: 0, + backgroundColor: 'transparent', + borderColor: '#007bf0', + borderWidth: 4, + pointBackgroundColor: '#007bff' + }] }, options: { - scales: { - yAxes: [{ - ticks: { - beginAtZero: false - } - }] - }, - legend: { - display: false - } + scales: { + yAxes: [{ + ticks: { + beginAtZero: false + } + }] + }, + legend: { + display: false + } } }) })() diff --git a/vrobbler/templates/scrobbles/scrobble_list.html b/vrobbler/templates/scrobbles/scrobble_list.html index 9228023..a5d541c 100644 --- a/vrobbler/templates/scrobbles/scrobble_list.html +++ b/vrobbler/templates/scrobbles/scrobble_list.html @@ -20,80 +20,109 @@ - -

Top this week

-
- - - - - - - - - - - {% for track in top_weekly_tracks %} - - - - - - - {% endfor %} - -
#TrackArtistAlbum
{{track.num_scrobbles}}{{track.title}}{{track.artist.name}}{{track.album.name}}
+
+
+
+

Top artists this week

+
+ + + + + + + + + {% for artist in top_weekly_artists %} + + + + + {% endfor %} + +
#Artist
{{artist.num_scrobbles}}{{artist.name}}
+
+
+
+

Top tracks this week

+
+ + + + + + + + + + {% for track in top_weekly_tracks %} + + + + + + {% endfor %} + +
#TrackArtist
{{track.num_scrobbles}}{{track.title}}{{track.artist.name}}
+
+
+
+
+
+
+

Latest listened

+

Today {{counts.today}} | This Week {{counts.week}} | This Month {{counts.month}} | This Year {{counts.year}} | All Time {{counts.alltime}}

+
+ + + + + + + + + + + {% for scrobble in object_list %} + + + + + + + {% endfor %} + +
TimeTrackArtistSource
{{scrobble.timestamp|naturaltime}}{{scrobble.track.title}}{{scrobble.track.artist.name}}{{scrobble.source}}
+
+
-

Latest scrobbles

-

Today {{counts.today}} | This Week {{counts.week}} | This Month {{counts.month}} | This Year {{counts.year}} | All Time {{counts.alltime}}

-
- - - - - - - - - - - {% for scrobble in object_list %} - - - - - - - {% endfor %} - -
TimeTrackArtistSource
{{scrobble.timestamp|naturaltime}}{{scrobble.track.title}}{{scrobble.track.artist.name}}{{scrobble.source}}
-
- -

Latest watched

-
- - - - - - - - - - - - {% for scrobble in video_scrobble_list %} - - - - - - - - {% endfor %} - -
TimeTitleSeriesSeason & EpisodeSource
{{scrobble.timestamp|naturaltime}}{{scrobble.video.title}}{% if scrobble.video.tv_series %}{{scrobble.video.tv_series}}{% endif %}{% if scrobble.video.tv_series %}{{scrobble.video.season_number}}, {{scrobble.video.episode_number}}{% endif %}{{scrobble.source}}
+
+

Latest watched

+
+ + + + + + + + + + + {% for scrobble in video_scrobble_list %} + + + + + + + {% endfor %} + +
TimeTitleSeriesSource
{{scrobble.timestamp|naturaltime}}{% if scrobble.video.tv_series %}E{{scrobble.video.season_number}}S{{scrobble.video.season_number}} -{% endif %} {{scrobble.video.title}}{% if scrobble.video.tv_series %}{{scrobble.video.tv_series}}{% endif %}{{scrobble.source}}
+
+
+
{% endblock %}