test APi evolution add filter to retrieve last results
[releng.git] / utils / test / result_collection_api / opnfv_testapi / resources / handlers.py
index 3d39502..df920c4 100644 (file)
@@ -106,11 +106,15 @@ class GenericApiHandler(RequestHandler):
 
     @asynchronous
     @gen.coroutine
-    def _list(self, query=None, res_op=None, *args):
+    def _list(self, query=None, res_op=None, *args, **kwargs):
         if query is None:
             query = {}
         data = []
         cursor = self._eval_db(self.table, 'find', query)
+        if 'sort' in kwargs:
+            cursor = cursor.sort(kwargs.get('sort'))
+        if 'last' in kwargs:
+            cursor = cursor.limit(kwargs.get('last'))
         while (yield cursor.fetch_next):
             data.append(self.format_data(cursor.next_object()))
         if res_op is None: