From 8f2ea10be296f406de3af4116c9b2300141643ea Mon Sep 17 00:00:00 2001 From: Krateng Date: Sat, 16 Feb 2019 16:28:32 +0100 Subject: [PATCH] Organizing --- database.py | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/database.py b/database.py index a050352..59e8e5c 100644 --- a/database.py +++ b/database.py @@ -174,7 +174,18 @@ def get_scrobbles(**keys): -# DEPRECATED, merge with /amounts + + +# DEPRECATED +# UNUSED +@dbserver.route("/amounts") +def get_amounts_external(): + return get_amounts() #really now + +def get_amounts(): + return {"scrobbles":len(SCROBBLES),"tracks":len(TRACKS),"artists":len(ARTISTS)} + + @dbserver.route("/numscrobbles") def get_scrobbles_num_external(): keys = FormsDict.decode(request.query) @@ -190,6 +201,22 @@ def get_scrobbles_num(**keys): r = db_query(**{k:keys[k] for k in keys if k in ["artists","title","since","to","within","associated"]}) return len(r) +# DEPRECATED +# UNUSED +@dbserver.route("/charts") +def get_charts_external(): + keys = FormsDict.decode(request.query) + ckeys = {} + ckeys["since"], ckeys["to"], ckeys["within"] = keys.get("since"), keys.get("to"), keys.get("in") + + result = get_scrobbles_num(**ckeys) + return {"number":result} + +#def get_charts(**keys): +# return db_aggregate(**{k:keys[k] for k in keys if k in ["since","to","within"]}) + + + @@ -199,7 +226,7 @@ def get_tracks_external(): keys = FormsDict.decode(request.query) ckeys = {} ckeys["artist"] = keys.get("artist") - + result = get_tracks(**ckeys) return {"list":result} @@ -229,13 +256,6 @@ def get_artists(): -@dbserver.route("/amounts") -def get_amounts_external(): - return get_amounts() #really now - -def get_amounts(): - return {"scrobbles":len(SCROBBLES),"tracks":len(TRACKS),"artists":len(ARTISTS)} - @@ -272,23 +292,6 @@ def get_charts_tracks(**keys): - - - -# DEPRECATED, merge with /amounts -@dbserver.route("/charts") -def get_charts_external(): - keys = FormsDict.decode(request.query) - ckeys = {} - ckeys["since"], ckeys["to"], ckeys["within"] = keys.get("since"), keys.get("to"), keys.get("in") - - result = get_charts(**ckeys) - return {"number":result} - -def get_charts(**keys): - return db_aggregate(**{k:keys[k] for k in keys if k in ["since","to","within"]}) - -