1
0
mirror of https://github.com/krateng/maloja.git synced 2023-08-10 21:12:55 +03:00

Added weeks on #1 stat to artist and track pages

This commit is contained in:
Krateng 2019-06-27 10:40:38 +02:00
parent ae5b0fc90c
commit 495b00803d
8 changed files with 33 additions and 4 deletions

View File

@ -535,7 +535,14 @@ def artistInfo(artist):
c = [e for e in charts if e["artist"] == artist][0] c = [e for e in charts if e["artist"] == artist][0]
others = [a for a in coa.getAllAssociated(artist) if a in ARTISTS] others = [a for a in coa.getAllAssociated(artist) if a in ARTISTS]
position = c["rank"] position = c["rank"]
return {"scrobbles":scrobbles,"position":position,"associated":others,"medals":MEDALS.get(artist)} performance = get_performance(artist=artist,step="week")
return {
"scrobbles":scrobbles,
"position":position,
"associated":others,
"medals":MEDALS.get(artist),
"topweeks":len([p for p in performance if p["rank"] == 1])
}
except: except:
# if the artist isnt in the charts, they are not being credited and we # if the artist isnt in the charts, they are not being credited and we
# need to show information about the credited one # need to show information about the credited one
@ -567,6 +574,7 @@ def trackInfo(track):
c = [e for e in charts if e["track"] == track][0] c = [e for e in charts if e["track"] == track][0]
scrobbles = c["scrobbles"] scrobbles = c["scrobbles"]
position = c["rank"] position = c["rank"]
performance = get_performance(track=track,step="week")
cert = None cert = None
threshold_gold, threshold_platinum, threshold_diamond = settings.get_settings("SCROBBLES_GOLD","SCROBBLES_PLATINUM","SCROBBLES_DIAMOND") threshold_gold, threshold_platinum, threshold_diamond = settings.get_settings("SCROBBLES_GOLD","SCROBBLES_PLATINUM","SCROBBLES_DIAMOND")
if scrobbles >= threshold_diamond: cert = "diamond" if scrobbles >= threshold_diamond: cert = "diamond"
@ -577,7 +585,8 @@ def trackInfo(track):
"scrobbles":scrobbles, "scrobbles":scrobbles,
"position":position, "position":position,
"medals":MEDALS_TRACKS.get((frozenset(track["artists"]),track["title"])), "medals":MEDALS_TRACKS.get((frozenset(track["artists"]),track["title"])),
"certification":cert "certification":cert,
"topweeks":len([p for p in performance if p["rank"] == 1])
} }

View File

@ -22,7 +22,7 @@
<p class="stats"><a href="/scrobbles?artist=KEY_ENC_ARTISTNAME">KEY_SCROBBLES Scrobbles</a></p> <p class="stats"><a href="/scrobbles?artist=KEY_ENC_ARTISTNAME">KEY_SCROBBLES Scrobbles</a></p>
<p class="desc">KEY_DESCRIPTION</p> <p class="desc">KEY_DESCRIPTION</p>
<span>KEY_MEDALS</span> <span>KEY_CERTS</span> <span>KEY_MEDALS</span> <span>KEY_TOPWEEKS</span> <span>KEY_CERTS</span>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -41,6 +41,13 @@ def instructions(keys):
html_cert += "<a href='{link}'><img class='certrecord_small' src='{img}' title='{tooltip}' /></a>".format(tooltip=tooltip,img=img,link=tracklink) html_cert += "<a href='{link}'><img class='certrecord_small' src='{img}' title='{tooltip}' /></a>".format(tooltip=tooltip,img=img,link=tracklink)
html_topweeks = ""
if data.get("topweeks") not in [0,None]:
link = "/performance?artist=" + urllib.parse.quote(keys["artist"]) + "&trail=1&step=week"
title = str(data["topweeks"]) + " weeks on #1"
html_topweeks = "<a title='" + title + "' href='" + link + "'><img class='star' src='/media/star.png' />" + str(data["topweeks"]) + "</a>"
credited = data.get("replace") credited = data.get("replace")
includestr = " " includestr = " "
if credited is not None: if credited is not None:
@ -81,6 +88,7 @@ def instructions(keys):
"KEY_ASSOCIATED":includestr, "KEY_ASSOCIATED":includestr,
"KEY_MEDALS":html_medals, "KEY_MEDALS":html_medals,
"KEY_CERTS":html_cert, "KEY_CERTS":html_cert,
"KEY_TOPWEEKS":html_topweeks,
# tracks # tracks
"KEY_TRACKLIST":html_tracks, "KEY_TRACKLIST":html_tracks,
# pulse # pulse

View File

@ -389,6 +389,11 @@ img.certrecord_small {
vertical-align: text-bottom; vertical-align: text-bottom;
} }
img.star {
height:20px;
vertical-align: text-bottom;
}
/* /*
** **

BIN
website/media/star.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

BIN
website/media/star_alt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@ -21,7 +21,7 @@
<p class="stats"><a href="/scrobbles?KEY_SCROBBLELINK">KEY_SCROBBLES Scrobbles</a></p> <p class="stats"><a href="/scrobbles?KEY_SCROBBLELINK">KEY_SCROBBLES Scrobbles</a></p>
<p class="desc"></p> <p class="desc"></p>
<span>KEY_MEDALS</span> <span>KEY_MEDALS</span> <span>KEY_TOPWEEKS</span>
</td> </td>
</tr> </tr>
</table> </table>

View File

@ -37,6 +37,12 @@ def instructions(keys):
for y in data["medals"]["bronze"]: for y in data["medals"]["bronze"]:
html_medals += "<a title='Third Best Track in " + str(y) + "' class='hidelink medal shiny bronze' href='/charts_tracks?in=" + str(y) + "'><span>" + str(y) + "</span></a>" html_medals += "<a title='Third Best Track in " + str(y) + "' class='hidelink medal shiny bronze' href='/charts_tracks?in=" + str(y) + "'><span>" + str(y) + "</span></a>"
html_topweeks = ""
if data.get("topweeks") not in [0,None]:
link = "/performance?" + compose_querystring(keys) + "&trail=1&step=week"
title = str(data["topweeks"]) + " weeks on #1"
html_topweeks = "<a title='" + title + "' href='" + link + "'><img class='star' src='/media/star.png' />" + str(data["topweeks"]) + "</a>"
html_scrobbles, _, _ = module_scrobblelist(track=track,max_=10,earlystop=True) # we have the number already from the trackinfo html_scrobbles, _, _ = module_scrobblelist(track=track,max_=10,earlystop=True) # we have the number already from the trackinfo
@ -65,6 +71,7 @@ def instructions(keys):
"KEY_SCROBBLELINK":compose_querystring(keys), "KEY_SCROBBLELINK":compose_querystring(keys),
"KEY_MEDALS":html_medals, "KEY_MEDALS":html_medals,
"KEY_CERTS":html_cert, "KEY_CERTS":html_cert,
"KEY_TOPWEEKS":html_topweeks,
"KEY_SCROBBLELIST":html_scrobbles, "KEY_SCROBBLELIST":html_scrobbles,
# pulse # pulse
"KEY_PULSE_MONTHS":html_pulse_months, "KEY_PULSE_MONTHS":html_pulse_months,