mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Added chart performance database call
This commit is contained in:
parent
7d04ea3953
commit
b3423dabcf
37
database.py
37
database.py
@ -394,6 +394,43 @@ def get_pulse(**keys):
|
||||
|
||||
|
||||
|
||||
@dbserver.route("/performance")
|
||||
def get_performance_external():
|
||||
keys = FormsDict.decode(request.query)
|
||||
k_filter, k_time, k_internal, k_amount = uri_to_internal(keys)
|
||||
ckeys = {**k_filter, **k_time, **k_internal, **k_amount}
|
||||
|
||||
results = get_performance(**ckeys)
|
||||
return {"list":results}
|
||||
|
||||
def get_performance(**keys):
|
||||
|
||||
rngs = ranges(**{k:keys[k] for k in keys if k in ["since","to","within","step","stepn","trail"]})
|
||||
results = []
|
||||
|
||||
for (a,b) in rngs:
|
||||
if "track" in keys:
|
||||
charts = get_charts_tracks(since=a,to=b)
|
||||
rank = None
|
||||
for c in charts:
|
||||
if c["track"] == keys["track"]:
|
||||
rank = c["rank"]
|
||||
break
|
||||
elif "artist" in keys:
|
||||
charts = get_charts_artists(since=a,to=b)
|
||||
rank = None
|
||||
for c in charts:
|
||||
if c["artist"] == keys["artist"]:
|
||||
rank = c["rank"]
|
||||
break
|
||||
results.append({"from":a,"to":b,"rank":rank})
|
||||
|
||||
return results
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ def instructions(keys):
|
||||
newdate = tod - d
|
||||
weekstart = [newdate.year,newdate.month,newdate.day]
|
||||
|
||||
clock()
|
||||
#clock()
|
||||
|
||||
# artists
|
||||
|
||||
@ -30,7 +30,7 @@ def instructions(keys):
|
||||
topartists_month = module_artistcharts_tiles(since="month")
|
||||
topartists_week = module_artistcharts_tiles(since=weekstart)
|
||||
|
||||
clockp("Artists")
|
||||
#clockp("Artists")
|
||||
|
||||
# tracks
|
||||
|
||||
@ -40,7 +40,7 @@ def instructions(keys):
|
||||
toptracks_week = module_trackcharts_tiles(since=weekstart)
|
||||
|
||||
|
||||
clockp("Tracks")
|
||||
#clockp("Tracks")
|
||||
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ def instructions(keys):
|
||||
# scrobbles
|
||||
html_scrobbles, _, _ = module_scrobblelist(max_=15,shortTimeDesc=True,pictures=True,earlystop=True)
|
||||
|
||||
clockp("Scrobbles")
|
||||
#clockp("Scrobbles")
|
||||
|
||||
# stats
|
||||
|
||||
@ -69,7 +69,7 @@ def instructions(keys):
|
||||
amount_total = database.get_scrobbles_num()
|
||||
scrobbles_total = "<a href='/scrobbles'>" + str(amount_total) + "</a>"
|
||||
|
||||
clockp("Amounts")
|
||||
#clockp("Amounts")
|
||||
|
||||
# pulse
|
||||
dt = datetime.utcnow()
|
||||
@ -91,7 +91,7 @@ def instructions(keys):
|
||||
#html_pulse_month = module_pulse(max_=30,since=[dt.year,dt.month],step="day",trail=1)
|
||||
#html_pulse_year = module_pulse(max_=12,since=[dt.year],step="month",trail=1)
|
||||
|
||||
clockp("Pulse")
|
||||
#clockp("Pulse")
|
||||
|
||||
#pushresources = [{"file":img,"type":"image"} for img in artistimages + trackimages] #can't push scrobble images as we don't get them from the module function, need to think about that
|
||||
pushresources = []
|
||||
|
Loading…
Reference in New Issue
Block a user