diff --git a/maloja/database/__init__.py b/maloja/database/__init__.py index 067060b..847e5f1 100644 --- a/maloja/database/__init__.py +++ b/maloja/database/__init__.py @@ -384,8 +384,8 @@ def get_tracks_without_album(dbconn=None,resolve_ids=True): @waitfordb def get_charts_artists(dbconn=None,resolve_ids=True,**keys): (since,to) = keys.get('timerange').timestamps() - associated = keys.get('associated',True) - result = sqldb.count_scrobbles_by_artist(since=since,to=to,resolve_ids=resolve_ids,associated=associated,dbconn=dbconn) + separate = keys.get('separate',False) + result = sqldb.count_scrobbles_by_artist(since=since,to=to,resolve_ids=resolve_ids,associated=(not separate),dbconn=dbconn) for entry in result: if "artist" in entry: entry['associated_artists'] = sqldb.get_associated_artists(entry['artist']) diff --git a/maloja/malojauri.py b/maloja/malojauri.py index d996f36..6546317 100644 --- a/maloja/malojauri.py +++ b/maloja/malojauri.py @@ -78,6 +78,7 @@ def uri_to_internal(keys,forceTrack=False,forceArtist=False,forceAlbum=False,api #5 specialkeys = {} if "remote" in keys: specialkeys["remote"] = keys["remote"] + specialkeys["separate"] = (keys.get('separate','no').lower() == 'yes') return filterkeys, limitkeys, delimitkeys, amountkeys, specialkeys @@ -144,6 +145,9 @@ def internal_to_uri(keys): if "perpage" in keys: urikeys.append("perpage",str(keys["perpage"])) + if keys.get("separate",False): + urikeys.append("separate","yes") + return urikeys diff --git a/maloja/web/jinja/charts_artists.jinja b/maloja/web/jinja/charts_artists.jinja index 627f38c..cd1be3a 100644 --- a/maloja/web/jinja/charts_artists.jinja +++ b/maloja/web/jinja/charts_artists.jinja @@ -7,7 +7,10 @@ {% endblock %} -{% set charts = dbc.get_charts_artists(filterkeys,limitkeys) %} +{% set charts = dbc.get_charts_artists(filterkeys,limitkeys,specialkeys) %} + + + {% set pages = math.ceil(charts.__len__() / amountkeys.perpage) %} {% if charts[0] is defined %} {% set topartist = charts[0].artist %} diff --git a/maloja/web/jinja/partials/charts_artists.jinja b/maloja/web/jinja/partials/charts_artists.jinja index c0067cf..4cd0063 100644 --- a/maloja/web/jinja/partials/charts_artists.jinja +++ b/maloja/web/jinja/partials/charts_artists.jinja @@ -2,7 +2,7 @@ {% import 'snippets/entityrow.jinja' as entityrow %} {% if charts is undefined %} - {% set charts = dbc.get_charts_artists(limitkeys) %} + {% set charts = dbc.get_charts_artists(limitkeys,specialkeys) %} {% endif %} {% if compare %} @@ -11,7 +11,7 @@ {% if compare is none %}{% set compare = False %}{% endif %} {% endif %} {% if compare %} - {% set prevartists = dbc.get_charts_artists({'timerange':compare}) %} + {% set prevartists = dbc.get_charts_artists({'timerange':compare},specialkeys) %} {% set lastranks = {} %} {% for a in prevartists %} @@ -49,11 +49,11 @@ {% endif %} - {{ entityrow.row(e['artist'],adminmode=adminmode,counting=e.associated_artists) }} + {{ entityrow.row(e['artist'],adminmode=adminmode,counting=([] if specialkeys.separate else e.associated_artists)) }} - {{ links.link_scrobbles([{'artist':e['artist'],'associated':True,'timerange':limitkeys.timerange}],amount=e['scrobbles']) }} - {{ links.link_scrobbles([{'artist':e['artist'],'associated':True,'timerange':limitkeys.timerange}],percent=e['scrobbles']*100/maxbar) }} + {{ links.link_scrobbles([{'artist':e['artist'],'associated':(not specialkeys.separate),'timerange':limitkeys.timerange}],amount=e['scrobbles']) }} + {{ links.link_scrobbles([{'artist':e['artist'],'associated':(not specialkeys.separate),'timerange':limitkeys.timerange}],percent=e['scrobbles']*100/maxbar) }} {% endif %} {% endfor %} diff --git a/maloja/web/jinja/snippets/timeselection.jinja b/maloja/web/jinja/snippets/timeselection.jinja index fe8b1d6..efd5f4c 100644 --- a/maloja/web/jinja/snippets/timeselection.jinja +++ b/maloja/web/jinja/snippets/timeselection.jinja @@ -1,7 +1,7 @@ - {% set allkeys = [filterkeys,limitkeys,delimitkeys,amountkeys] | combine_dicts %} + {% set allkeys = [filterkeys,limitkeys,delimitkeys,amountkeys,specialkeys] | combine_dicts %} @@ -13,7 +13,7 @@ {% set nextrange = thisrange.next(1) %} {% if prevrange is not none %} - {{ prevrange.desc() }} + {{ prevrange.desc() }} « {% endif %} {% if prevrange is not none or nextrange is not none %} @@ -21,7 +21,7 @@ {% endif %} {% if nextrange is not none %} » - {{ nextrange.desc() }} + {{ nextrange.desc() }} {% endif %}