add filter based on begin&end time of start_date 77/35777/4
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Mon, 5 Jun 2017 07:44:16 +0000 (15:44 +0800)
committerSerenaFeng <feng.xiaowei@zte.com.cn>
Wed, 7 Jun 2017 02:42:45 +0000 (10:42 +0800)
filter of 'Start Date' & 'End Date' in Community Results page now works,
currently, only 20 records will be shown due to pagination is not
supported.
From server side, query from date to date is supported now, query as:
/api/v1/results?from=2016-11-01%2000:00:00&to=2017-06-01%2023:59:59

Change-Id: I482b117129dbae38fa5a2858a86442c80d87d19e
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
utils/test/testapi/3rd_party/static/testapi-ui/components/results/resultsController.js
utils/test/testapi/opnfv_testapi/resources/result_handlers.py

index 39ace00..93a549a 100644 (file)
             var start = $filter('date')(ctrl.startDate, 'yyyy-MM-dd');
             if (start) {
                 content_url =
-                    content_url + '&start_date=' + start + ' 00:00:00';
+                    content_url + '&from=' + start + ' 00:00:00';
             }
             var end = $filter('date')(ctrl.endDate, 'yyyy-MM-dd');
             if (end) {
-                content_url = content_url + '&end_date=' + end + ' 23:59:59';
+                content_url = content_url + '&to=' + end + ' 23:59:59';
             }
             if (ctrl.isUserResults) {
                 content_url = content_url + '&signed';
index b84d1e3..824a89e 100644 (file)
@@ -35,6 +35,8 @@ class GenericResultHandler(handlers.GenericApiHandler):
 
     def set_query(self):
         query = dict()
+        date_range = dict()
+
         for k in self.request.query_arguments.keys():
             v = self.get_query_argument(k)
             if k == 'project' or k == 'pod' or k == 'case':
@@ -47,8 +49,14 @@ class GenericResultHandler(handlers.GenericApiHandler):
                     query['start_date'] = obj
             elif k == 'trust_indicator':
                 query[k + '.current'] = float(v)
+            elif k == 'from':
+                date_range.update({'$gte': str(v)})
+            elif k == 'to':
+                date_range.update({'$lt': str(v)})
             elif k != 'last' and k != 'page':
                 query[k] = v
+            if date_range:
+                query['start_date'] = date_range
         return query
 
 
@@ -64,9 +72,11 @@ class ResultsCLHandler(GenericResultHandler):
                  - case : case name
                  - pod : pod name
                  - version : platform version (Arno-R1, ...)
-                 - installer (fuel, ...)
+                 - installer : fuel/apex/compass/joid/daisy
                  - build_tag : Jenkins build tag name
-                 - period : x (x last days)
+                 - period : x last days, incompatible with from/to
+                 - from : starting time in 2016-01-01 or 2016-01-01 00:01:23
+                 - to : ending time in 2016-01-01 or 2016-01-01 00:01:23
                  - scenario : the test scenario (previously version)
                  - criteria : the global criteria status passed or failed
                  - trust_indicator : evaluate the stability of the test case
@@ -113,6 +123,14 @@ class ResultsCLHandler(GenericResultHandler):
             @type period: L{string}
             @in period: query
             @required period: False
+            @param from: i.e. 2016-01-01 or 2016-01-01 00:01:23
+            @type from: L{string}
+            @in from: query
+            @required from: False
+            @param to: i.e. 2016-01-01 or 2016-01-01 00:01:23
+            @type to: L{string}
+            @in to: query
+            @required to: False
             @param last: last records stored until now
             @type last: L{string}
             @in last: query