[odrs-web: 2/4] Make it possible to fetch from a starting point




commit 83525113c4edf6b824265b2e9e8a64503679b089
Author: Aleix Pol <aleixpol kde org>
Date:   Tue Aug 27 17:27:37 2019 +0200

    Make it possible to fetch from a starting point
    
    Introduce a start get argument in requests

 app_data/odrs/views_api.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/app_data/odrs/views_api.py b/app_data/odrs/views_api.py
index 324cd0c..d61cacb 100644
--- a/app_data/odrs/views_api.py
+++ b/app_data/odrs/views_api.py
@@ -268,8 +268,14 @@ def api_fetch():
 
     # sort and cut to limit
     items_new.sort(key=lambda item: item['score'], reverse=True)
-    if item['limit'] > 0:
-        items_new = items_new[:item['limit']]
+
+    if item['limit'] == 0:
+        limit = 50
+    else:
+        limit = item.get('limit', -1)
+
+    start = item.get('start', 0)
+    items_new = items_new[start : start+limit]
 
     dat = json.dumps(items_new, sort_keys=True, indent=4, separators=(',', ': '))
     return Response(response=dat,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]