Added associated UI distinction for artist pulse

This commit is contained in:
krateng 2023-10-28 22:50:12 +02:00
parent bad5fe7ce1
commit f6f1db6eac
4 changed files with 19 additions and 7 deletions

View File

@ -9,6 +9,7 @@ minor_release_name: "Nicole"
- "[Feature] Added UI for track-artist, track-album and album-artist association"
- "[Feature] Added inline UI for association and merging in chart lists"
- "[Feature] Added UI selector for including associated artists"
- "[Feature] Added UI distinction for associated scrobbles in chart bars"
- "[Performance] Improved image rendering"
- "[Performance] Optimized several database calls"
- "[Bugfix] Fixed configuration of time format"

View File

@ -471,7 +471,12 @@ def get_pulse(dbconn=None,**keys):
continue
res = get_scrobbles_num(timerange=rng,**{k:keys[k] for k in keys if k != 'timerange'},dbconn=dbconn)
results.append({"range":rng,"scrobbles":res})
if keys.get('artist') and keys.get('associated',False):
res_real = get_scrobbles_num(timerange=rng,**{k:keys[k] for k in keys if k not in ['timerange','associated']},associated=False,dbconn=dbconn)
# this isnt really efficient, we could do that in one db call, but i dont wanna reorganize rn
else:
res_real = res
results.append({"range":rng,"scrobbles":res,"real_scrobbles":res_real})
return results

View File

@ -853,8 +853,7 @@ def get_scrobbles_of_artist(artist,since=None,to=None,resolve_references=True,li
jointable = sql.join(DB['scrobbles'],DB['trackartists'],DB['scrobbles'].c.track_id == DB['trackartists'].c.track_id)
op = jointable.select().where(
DB['scrobbles'].c.timestamp<=to,
DB['scrobbles'].c.timestamp>=since,
DB['scrobbles'].c.timestamp.between(since,to),
DB['trackartists'].c.artist_id.in_(artist_ids)
)
if reverse:
@ -870,9 +869,9 @@ def get_scrobbles_of_artist(artist,since=None,to=None,resolve_references=True,li
seen = set()
filtered_result = []
for row in result:
if row.timestamp not in seen:
filtered_result.append(row)
seen.add(row.timestamp)
if row.timestamp not in seen:
filtered_result.append(row)
seen.add(row.timestamp)
result = filtered_result

View File

@ -15,7 +15,14 @@
{{ links.link_scrobbles([filterkeys,{'timerange':thisrange}],amount=t.scrobbles) }}
</td>
<td class="bar">
{{ links.link_scrobbles([filterkeys,{'timerange':thisrange}],percent=t.scrobbles*100/maxbar) }}
{% if 'artist' in filterkeys and filterkeys.get('associated') %}
{{ links.link_scrobbles([{'artist':filterkeys.artist,'associated':False,'timerange':thisrange}],percent=t.real_scrobbles*100/maxbar) }}
{%- if t.real_scrobbles != t.scrobbles -%}
{{ links.link_scrobbles([{'artist':filterkeys.artist,'associated':True,'timerange':thisrange}],percent=(t.scrobbles-t.real_scrobbles)*100/maxbar) }}
{%- endif %}
{% else %}
{{ links.link_scrobbles([filterkeys,{'timerange':thisrange}],percent=t.scrobbles*100/maxbar) }}
{% endif %}
</td>
</tr>
{% endfor %}