From 42833c8d09610a81ec5f21254db7d7217c027b4e Mon Sep 17 00:00:00 2001 From: Krateng Date: Fri, 15 Feb 2019 18:11:40 +0100 Subject: [PATCH] First test separation of API get and actual function --- database.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/database.py b/database.py index 58d2074..184eeab 100644 --- a/database.py +++ b/database.py @@ -138,10 +138,12 @@ def test_server(): # 403 Database server is up, but provided API key is not valid @dbserver.route("/scrobbles") -def get_scrobbles(): +def get_scrobbles_external(): keys = FormsDict.decode(request.query) - - r = db_query(artists=keys.getall("artist"),title=keys.get("title"),since=keys.get("since"),to=keys.get("to"),within=keys.get("in"),associated=(keys.get("associated")!=None)) + return get_scrobbles(artists=keys.getall("artist"),title=keys.get("title"),since=keys.get("since"),to=keys.get("to"),within=keys.get("in"),associated=(keys.get("associated")!=None),max=keys.get("max")) + +def get_scrobbles(**keys): + r = db_query(**{k:keys[k] for k in keys if k in ["artists","title","since","to","within","associated"]}) r.reverse() if keys.get("max") is not None: @@ -150,7 +152,7 @@ def get_scrobbles(): return {"list":r} ##json can't be a list apparently??? @dbserver.route("/numscrobbles") -def get_scrobbles(): +def get_scrobbles_num(): keys = FormsDict.decode(request.query) r = db_query(artists=keys.getall("artist"),title=keys.get("title"),since=keys.get("since"),to=keys.get("to"),within=keys.get("in"),associated=(keys.get("associated")!=None))