mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
There was an attempt
This commit is contained in:
parent
0de84629bb
commit
f0010fd6bb
32
database.py
32
database.py
@ -214,6 +214,38 @@ def get_scrobbles_num(**keys):
|
||||
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
|
||||
#@dbserver.route("/charts")
|
||||
#def get_charts_external():
|
||||
|
10
utilities.py
10
utilities.py
@ -280,6 +280,16 @@ def loadCache():
|
||||
finally:
|
||||
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):
|
||||
|
||||
obj = (frozenset(artists),title)
|
||||
|
@ -43,18 +43,23 @@ def instructions(keys):
|
||||
clock("Scrobbles")
|
||||
|
||||
# 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")
|
||||
scrobbles_month = "<a href='/scrobbles?since=month'>" + str(amount) + "</a>"
|
||||
#(amount_day,amount_month,amount_year,amount_total) = database.get_scrobbles_num_multiple(("today","month","year",None))
|
||||
#amount_month += amount_day
|
||||
#amount_year += amount_month
|
||||
#amount_total += amount_year
|
||||
|
||||
amount = database.get_scrobbles_num(since="year")
|
||||
scrobbles_year = "<a href='/scrobbles?since=year'>" + str(amount) + "</a>"
|
||||
amount_day = database.get_scrobbles_num(since="today")
|
||||
scrobbles_today = "<a href='/scrobbles?since=today'>" + str(amount_day) + "</a>"
|
||||
|
||||
amount = database.get_scrobbles_num()
|
||||
scrobbles_total = "<a href='/scrobbles'>" + str(amount) + "</a>"
|
||||
amount_month = database.get_scrobbles_num(since="month")
|
||||
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")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user