From c4a9c6dc0f7ae4abe3645048609c8060235346bb Mon Sep 17 00:00:00 2001 From: Krateng Date: Tue, 12 Jan 2021 18:47:18 +0100 Subject: [PATCH] Fixed scrobbles view --- maloja/apis/native_v1.py | 5 +++++ maloja/database.py | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/maloja/apis/native_v1.py b/maloja/apis/native_v1.py index 5fa05e6..e3ca23f 100644 --- a/maloja/apis/native_v1.py +++ b/maloja/apis/native_v1.py @@ -57,6 +57,11 @@ def get_scrobbles_external(**keys): ckeys = {**k_filter, **k_time, **k_amount} result = get_scrobbles(**ckeys) + + offset = (k_amount.get('page') * k_amount.get('perpage')) if k_amount.get('perpage') is not math.inf else 0 + result = result[offset:] + if k_amount.get('perpage') is not math.inf: result = result[:k_amount.get('perpage')] + return {"list":result} diff --git a/maloja/database.py b/maloja/database.py index 7830dac..c058dd8 100644 --- a/maloja/database.py +++ b/maloja/database.py @@ -269,9 +269,9 @@ def api_key_correct(request): def get_scrobbles(**keys): r = db_query(**{k:keys[k] for k in keys if k in ["artist","artists","title","since","to","within","timerange","associated","track"]}) - offset = (keys.get('page') * keys.get('perpage')) if keys.get('perpage') is not math.inf else 0 - r = r[offset:] - if keys.get('perpage') is not math.inf: r = r[:keys.get('perpage')] + #offset = (keys.get('page') * keys.get('perpage')) if keys.get('perpage') is not math.inf else 0 + #r = r[offset:] + #if keys.get('perpage') is not math.inf: r = r[:keys.get('perpage')] return r