There was an attempt

This commit is contained in:
Krateng 2019-03-12 16:06:09 +01:00
parent 0de84629bb
commit f0010fd6bb
3 changed files with 58 additions and 11 deletions

View File

@ -214,6 +214,38 @@ def get_scrobbles_num(**keys):
return len(r) return len(r)
#for multiple since values (must be ordered)
# DOESN'T SEEM TO ACTUALLY BE FASTER
# REEVALUATE
#def get_scrobbles_num_multiple(sinces=[],to=None,**keys):
#
# sinces_stamps = [time_stamps(since,to,None)[0] for since in sinces]
# #print(sinces)
# #print(sinces_stamps)
# minsince = sinces[-1]
# r = db_query(**{k:keys[k] for k in keys if k in ["artist","track","artists","title","associated","to"]},since=minsince)
#
# #print(r)
#
# validtracks = [0 for s in sinces]
#
# i = 0
# si = 0
# while True:
# if si == len(sinces): break
# if i == len(r): break
# if r[i]["time"] >= sinces_stamps[si]:
# validtracks[si] += 1
# else:
# si += 1
# continue
# i += 1
#
#
# return validtracks
# UNUSED # UNUSED
#@dbserver.route("/charts") #@dbserver.route("/charts")
#def get_charts_external(): #def get_charts_external():

View File

@ -280,6 +280,16 @@ def loadCache():
finally: finally:
fl.close() fl.close()
# remove corrupt caching from previous versions
for k in cachedTracks:
if cachedTracks[k] == "":
del cachedTracks[k]
log("Removed invalid cache key: " + str(k))
for k in cachedArtists:
if cachedArtists[k] == "":
del cachedArtists[k]
log("Removed invalid cache key: " + str(k))
def getTrackImage(artists,title,fast=False): def getTrackImage(artists,title,fast=False):
obj = (frozenset(artists),title) obj = (frozenset(artists),title)

View File

@ -43,18 +43,23 @@ def instructions(keys):
clock("Scrobbles") clock("Scrobbles")
# stats # stats
amount = database.get_scrobbles_num(since="today")
scrobbles_today = "<a href='/scrobbles?since=today'>" + str(amount) + "</a>"
amount = database.get_scrobbles_num(since="month") #(amount_day,amount_month,amount_year,amount_total) = database.get_scrobbles_num_multiple(("today","month","year",None))
scrobbles_month = "<a href='/scrobbles?since=month'>" + str(amount) + "</a>" #amount_month += amount_day
#amount_year += amount_month
#amount_total += amount_year
amount = database.get_scrobbles_num(since="year") amount_day = database.get_scrobbles_num(since="today")
scrobbles_year = "<a href='/scrobbles?since=year'>" + str(amount) + "</a>" scrobbles_today = "<a href='/scrobbles?since=today'>" + str(amount_day) + "</a>"
amount = database.get_scrobbles_num() amount_month = database.get_scrobbles_num(since="month")
scrobbles_total = "<a href='/scrobbles'>" + str(amount) + "</a>" scrobbles_month = "<a href='/scrobbles?since=month'>" + str(amount_month) + "</a>"
amount_year = database.get_scrobbles_num(since="year")
scrobbles_year = "<a href='/scrobbles?since=year'>" + str(amount_year) + "</a>"
amount_total = database.get_scrobbles_num()
scrobbles_total = "<a href='/scrobbles'>" + str(amount_total) + "</a>"
clock("Amounts") clock("Amounts")