The things I do for performance

This commit is contained in:
krateng 2023-10-27 20:05:02 +02:00
parent c0de2e6cd3
commit 936f4094eb
3 changed files with 7 additions and 3 deletions

View File

@ -605,7 +605,10 @@ def artist_info(dbconn=None,**keys):
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)
own_album_charts = get_charts_albums(timerange=alltime(),resolve_ids=True,artist=artist,dbconn=dbconn)
# we resolve ids here which we don't need to. however, on the jinja page we make that same call
# later again with resolve ids, so its a cache miss and it doubles page load time
# TODO: find better solution
if own_track_charts:
c = own_track_charts[0]
scrobbles = c["scrobbles"]

View File

@ -4,7 +4,7 @@
<div id="showcase_container">
{% for entry in dbc.get_charts_albums(filterkeys,limitkeys,{'appearing':False}) %}
{% for entry in dbc.get_charts_albums(filterkeys,limitkeys) %}
{%- set cert = None -%}
{%- if entry.scrobbles >= settings.scrobbles_gold_album -%}{% set cert = 'gold' %}{%- endif -%}

View File

@ -57,7 +57,8 @@
<!-- SUBCERTS -->
{% set albumcharts = dbc.get_charts_albums({'artist':artist,'timerange':malojatime.alltime()}) %}
{% set albumcharts = dbc.get_charts_albums({'artist':artist,'timerange':malojatime.alltime(),'resolve_ids':True}) %}
{# TODO: find better solution, we just resolve ids here because we have that in the cache anyway #}
{% for e in albumcharts -%}
{%- if e.scrobbles >= settings.scrobbles_gold_album -%}{% set cert = 'gold' %}{%- endif -%}
{%- if e.scrobbles >= settings.scrobbles_platinum_album -%}{% set cert = 'platinum' %}{%- endif -%}