From 5a575b9457e24414beb871858e372af4a1fbde7c Mon Sep 17 00:00:00 2001 From: Krateng Date: Tue, 23 Apr 2019 17:47:49 +0200 Subject: [PATCH] Added link between pulse and performance views --- database.py | 2 +- website/performance.html | 2 +- website/performance.py | 12 ++++++++++-- website/pulse.html | 2 +- website/pulse.py | 20 ++++++++++++++++++-- 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/database.py b/database.py index 130ece2..8310499 100644 --- a/database.py +++ b/database.py @@ -482,7 +482,7 @@ def get_top_tracks(**keys): rngs = ranges(**{k:keys[k] for k in keys if k in ["since","to","within","timerange","step","stepn","trail"]}) results = [] - for (a,b) in rngs: + for rng in rngs: try: res = db_aggregate(timerange=rng,by="TRACK")[0] results.append({"range":rng,"track":res["track"],"scrobbles":res["scrobbles"]}) diff --git a/website/performance.html b/website/performance.html index 5c368e6..196641e 100644 --- a/website/performance.html +++ b/website/performance.html @@ -13,7 +13,7 @@
-

KEY_PULSEDETAILS Performance


+

KEY_PULSEDETAILS Performance

KEY_PULSE_LINK
KEY_LIMITS

diff --git a/website/performance.py b/website/performance.py index 41e8499..48f49f1 100644 --- a/website/performance.py +++ b/website/performance.py @@ -5,12 +5,18 @@ import database def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink - from urihandler import compose_querystring, uri_to_internal + from urihandler import compose_querystring, uri_to_internal, internal_to_uri from htmlmodules import module_performance, module_filterselection from malojatime import range_desc, delimit_desc filterkeys, timekeys, delimitkeys, _ = uri_to_internal(keys) + #equivalent pulse chart + pulselink_keys = internal_to_uri({**filterkeys,**timekeys,**delimitkeys}) + pulselink = "/pulse?" + compose_querystring(pulselink_keys) + + pulselink = "View Pulse" + # describe the scope (and creating a key for the relevant artist or track) limitstring = "" @@ -50,7 +56,9 @@ def instructions(keys): html_performance = module_performance(**filterkeys,**timekeys,**delimitkeys) - replace = {"KEY_PERFORMANCE_TABLE":html_performance, + replace = { + "KEY_PULSE_LINK":pulselink, + "KEY_PERFORMANCE_TABLE":html_performance, "KEY_IMAGEURL":imgurl, "KEY_LIMITS":limitstring, "KEY_PULSEDETAILS":delimitstring, diff --git a/website/pulse.html b/website/pulse.html index 5d3a89d..385b4dc 100644 --- a/website/pulse.html +++ b/website/pulse.html @@ -13,7 +13,7 @@
-

KEY_PULSEDETAILS Pulse


+

KEY_PULSEDETAILS Pulse

KEY_RANKINGS_LINK
KEY_LIMITS

diff --git a/website/pulse.py b/website/pulse.py index beb701e..78572a5 100644 --- a/website/pulse.py +++ b/website/pulse.py @@ -5,12 +5,21 @@ import database def instructions(keys): from utilities import getArtistImage, getTrackImage from htmlgenerators import artistLink, artistLinks, trackLink, scrobblesLink - from urihandler import compose_querystring, uri_to_internal + from urihandler import compose_querystring, uri_to_internal, internal_to_uri from htmlmodules import module_pulse, module_filterselection from malojatime import range_desc, delimit_desc filterkeys, timekeys, delimitkeys, _ = uri_to_internal(keys) + #equivalent performance chart if we're not looking at the overall pulse + if len(filterkeys) != 0: + performancelink_keys = internal_to_uri({**filterkeys,**timekeys,**delimitkeys}) + performancelink = "/performance?" + compose_querystring(performancelink_keys) + + performancelink = "View Rankings" + else: + performancelink = "" + # describe the scope (and creating a key for the relevant artist or track) limitstring = "" @@ -50,6 +59,13 @@ def instructions(keys): html_pulse = module_pulse(**filterkeys,**timekeys,**delimitkeys) - replace = {"KEY_PULSE_TABLE":html_pulse,"KEY_IMAGEURL":imgurl,"KEY_LIMITS":limitstring,"KEY_PULSEDETAILS":delimitstring,"KEY_FILTERSELECTOR":html_filterselector} + replace = { + "KEY_RANKINGS_LINK":performancelink, + "KEY_PULSE_TABLE":html_pulse, + "KEY_IMAGEURL":imgurl, + "KEY_LIMITS":limitstring, + "KEY_PULSEDETAILS":delimitstring, + "KEY_FILTERSELECTOR":html_filterselector + } return (replace,pushresources)