[music] Fix slow loading artist page
This commit is contained in:
21
PROJECT.org
21
PROJECT.org
@ -93,7 +93,7 @@ fetching and simple saving.
|
|||||||
:LOGBOOK:
|
:LOGBOOK:
|
||||||
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
|
CLOCK: [2025-07-09 Wed 09:55]--[2025-07-09 Wed 10:15] => 0:20
|
||||||
:END:
|
:END:
|
||||||
* Backlog [-2/11] :vrobbler:project:personal:
|
* Backlog [1/14] :vrobbler:project:personal:
|
||||||
** TODO [#C] Add sentiment parsing for Scrobbles with notes :vrobbler:project:scrobbles:sentiment:
|
** TODO [#C] Add sentiment parsing for Scrobbles with notes :vrobbler:project:scrobbles:sentiment:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:ID: 37781d6a-f3b0-48b2-bf98-33c2c791cf85
|
:ID: 37781d6a-f3b0-48b2-bf98-33c2c791cf85
|
||||||
@ -489,6 +489,25 @@ whatever time KoReader reports, we need to know, given the date and the user
|
|||||||
profile's historic timezone, how many hours to adjust the KoReader time to get
|
profile's historic timezone, how many hours to adjust the KoReader time to get
|
||||||
to GMT to save it in the database.
|
to GMT to save it in the database.
|
||||||
|
|
||||||
|
** DONE [#B] Adjust how similar artists are shown :feature:templates:artists:music:
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 2a081620-a0a2-4851-a7cf-4043f9c2ee31
|
||||||
|
:END:
|
||||||
|
|
||||||
|
*** Description
|
||||||
|
|
||||||
|
Currently we show the top 10 similar artists on the Artist detail page linked to
|
||||||
|
the artist detail page on Vrobbler.
|
||||||
|
|
||||||
|
First off, this is very slow. We should look into speeding up the rendering of
|
||||||
|
the similar artists widget.
|
||||||
|
|
||||||
|
Second, the artist name in the similar artist list should be a link to the
|
||||||
|
Vrobbler artist detail page, but there should also be a [musicbrainz] link next
|
||||||
|
to it, that links out to the musicbrainz page whether we have the artist in the
|
||||||
|
Vrobbler database or not.
|
||||||
|
|
||||||
|
|
||||||
* Version 39.3 [2/2]
|
* Version 39.3 [2/2]
|
||||||
** DONE [#A] Issue found when doing a release :bug:tooling:release:cicd:
|
** DONE [#A] Issue found when doing a release :bug:tooling:release:cicd:
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
|||||||
@ -19,11 +19,7 @@ class ArtistListView(generic.ListView):
|
|||||||
paginate_by = 100
|
paginate_by = 100
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
qs = (
|
qs = super().get_queryset().annotate(scrobble_count=Count("track__scrobble"))
|
||||||
super()
|
|
||||||
.get_queryset()
|
|
||||||
.annotate(scrobble_count=Count("track__scrobble"))
|
|
||||||
)
|
|
||||||
genre = self.request.GET.get("genre")
|
genre = self.request.GET.get("genre")
|
||||||
if genre:
|
if genre:
|
||||||
qs = qs.filter(theaudiodb_genre=genre)
|
qs = qs.filter(theaudiodb_genre=genre)
|
||||||
@ -82,26 +78,30 @@ class ArtistDetailView(generic.DetailView):
|
|||||||
|
|
||||||
similar = artist.similar_artists or []
|
similar = artist.similar_artists or []
|
||||||
if similar:
|
if similar:
|
||||||
mbids = [sa["artist_mbid"] for sa in similar if sa.get("artist_mbid")]
|
top = similar[:10]
|
||||||
|
mbids = [sa["artist_mbid"] for sa in top if sa.get("artist_mbid")]
|
||||||
local_artists = {
|
local_artists = {
|
||||||
a.musicbrainz_id: a
|
a.musicbrainz_id: a
|
||||||
for a in Artist.objects.filter(musicbrainz_id__in=mbids)
|
for a in Artist.objects.filter(musicbrainz_id__in=mbids)
|
||||||
}
|
}
|
||||||
for sa in similar:
|
for sa in top:
|
||||||
local = local_artists.get(sa.get("artist_mbid"))
|
local = local_artists.get(sa.get("artist_mbid"))
|
||||||
sa["local_url"] = local.get_absolute_url() if local else None
|
sa["local_url"] = local.get_absolute_url() if local else None
|
||||||
context_data["similar_artists"] = similar
|
sa["musicbrainz_url"] = (
|
||||||
|
f"https://musicbrainz.org/artist/{sa['artist_mbid']}"
|
||||||
|
if sa.get("artist_mbid")
|
||||||
|
else None
|
||||||
|
)
|
||||||
|
context_data["similar_artists"] = top
|
||||||
|
|
||||||
if artist.theaudiodb_genre:
|
if artist.theaudiodb_genre:
|
||||||
context_data["genre_count"] = (
|
context_data["genre_count"] = Artist.objects.filter(
|
||||||
Artist.objects.filter(theaudiodb_genre=artist.theaudiodb_genre)
|
theaudiodb_genre=artist.theaudiodb_genre
|
||||||
.count()
|
).count()
|
||||||
)
|
|
||||||
if artist.theaudiodb_mood:
|
if artist.theaudiodb_mood:
|
||||||
context_data["mood_count"] = (
|
context_data["mood_count"] = Artist.objects.filter(
|
||||||
Artist.objects.filter(theaudiodb_mood=artist.theaudiodb_mood)
|
theaudiodb_mood=artist.theaudiodb_mood
|
||||||
.count()
|
).count()
|
||||||
)
|
|
||||||
|
|
||||||
return context_data
|
return context_data
|
||||||
|
|
||||||
|
|||||||
@ -53,13 +53,15 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Artist</th>
|
<th scope="col">Artist</th>
|
||||||
<th scope="col">Score</th>
|
<th scope="col">Score</th>
|
||||||
|
<th scope="col"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for sa in similar_artists|slice:":10" %}
|
{% for sa in similar_artists %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{% if sa.local_url %}<a href="{{sa.local_url}}">{{sa.name}}</a>{% else %}{{sa.name}}{% endif %}</td>
|
<td>{% if sa.local_url %}<a href="{{sa.local_url}}">{{sa.name}}</a>{% else %}{{sa.name}}{% endif %}</td>
|
||||||
<td>{{sa.score}}</td>
|
<td>{{sa.score}}</td>
|
||||||
|
<td>{% if sa.musicbrainz_url %}<a href="{{sa.musicbrainz_url}}">musicbrainz</a>{% endif %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user