Artists can now be pseudo-certified via their tracks or albums

This commit is contained in:
krateng 2023-10-26 19:47:43 +02:00
parent 964128fdff
commit 0e311e0ac8
2 changed files with 23 additions and 0 deletions

View File

@ -597,6 +597,24 @@ def artist_info(dbconn=None,**keys):
albums = sqldb.get_albums_of_artists(set([artist_id]),dbconn=dbconn)
isalbumartist = len(albums.get(artist_id,[]))>0
cert = None
own_track_charts = get_charts_tracks(timerange=alltime(),resolve_ids=False,artist=artist,dbconn=dbconn)
own_album_charts = get_charts_albums(timerange=alltime(),resolve_ids=False,artist=artist,dbconn=dbconn)
if own_track_charts:
c = own_track_charts[0]
scrobbles = c["scrobbles"]
threshold_gold, threshold_platinum, threshold_diamond = malojaconfig["SCROBBLES_GOLD","SCROBBLES_PLATINUM","SCROBBLES_DIAMOND"]
if scrobbles >= threshold_diamond: cert = "diamond"
elif scrobbles >= threshold_platinum: cert = "platinum"
elif scrobbles >= threshold_gold: cert = "gold"
if own_album_charts:
c = own_album_charts[0]
scrobbles = c["scrobbles"]
threshold_gold, threshold_platinum, threshold_diamond = malojaconfig["SCROBBLES_GOLD_ALBUM","SCROBBLES_PLATINUM_ALBUM","SCROBBLES_DIAMOND_ALBUM"]
if scrobbles >= threshold_diamond: cert = "diamond"
elif scrobbles >= threshold_platinum and cert != "diamond": cert = "platinum"
elif scrobbles >= threshold_gold and not cert: cert = "gold"
twk = thisweek()
tyr = thisyear()
@ -631,6 +649,7 @@ def artist_info(dbconn=None,**keys):
sqldb.count_scrobbles_by_artist(since=year.first_stamp(),to=year.last_stamp(),resolve_ids=False,dbconn=dbconn)
)]
},
"certification":cert,
"topweeks":len([
week for week in ranges(step="week") if (week != twk) and any(
(e.get('artist_id') == artist_id) and (e.get('rank') == 1) for e in

View File

@ -26,6 +26,10 @@
{% set encodedartist = mlj_uri.uriencode({'artist':artist}) %}
{% block custombodyclasses %}
{% if info.certification %}certified certified_{{ info.certification }}{% endif %}
{% endblock %}
{% block icon_bar %}
{% if adminmode %}
{% include 'icons/edit.jinja' %}