diff --git a/database.py b/database.py
index e77b9e8..ef8af5f 100644
--- a/database.py
+++ b/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():
@@ -871,7 +903,7 @@ def db_query_full(artist=None,artists=None,title=None,track=None,since=None,to=N
# pointless to check for artist when track is checked because every track has a fixed set of artists, but it's more elegant this way
-
+
# Queries that... well... aggregate
def db_aggregate_full(by=None,since=None,to=None,within=None,artist=None):
(since, to) = time_stamps(since,to,within)
diff --git a/utilities.py b/utilities.py
index 948b2dd..09aa337 100644
--- a/utilities.py
+++ b/utilities.py
@@ -279,6 +279,16 @@ def loadCache():
(cachedTracks, cachedArtists) = ob
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):
diff --git a/website/start.py b/website/start.py
index d9b23f6..bfad2b5 100644
--- a/website/start.py
+++ b/website/start.py
@@ -43,18 +43,23 @@ def instructions(keys):
clock("Scrobbles")
# stats
- amount = database.get_scrobbles_num(since="today")
- scrobbles_today = "" + str(amount) + ""
- amount = database.get_scrobbles_num(since="month")
- scrobbles_month = "" + str(amount) + ""
-
- amount = database.get_scrobbles_num(since="year")
- scrobbles_year = "" + str(amount) + ""
-
- amount = database.get_scrobbles_num()
- scrobbles_total = "" + str(amount) + ""
+ #(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_day = database.get_scrobbles_num(since="today")
+ scrobbles_today = "" + str(amount_day) + ""
+
+ amount_month = database.get_scrobbles_num(since="month")
+ scrobbles_month = "" + str(amount_month) + ""
+
+ amount_year = database.get_scrobbles_num(since="year")
+ scrobbles_year = "" + str(amount_year) + ""
+
+ amount_total = database.get_scrobbles_num()
+ scrobbles_total = "" + str(amount_total) + ""
clock("Amounts")