summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/resources/result_handlers.py
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2017-07-19 13:29:53 +0800
committerSerenaFeng <feng.xiaowei@zte.com.cn>2017-07-19 13:29:53 +0800
commit39fda4fb3d59b471e4d58e9929969a3c3ccc5387 (patch)
tree95038120596e06432b9e6c37cfd496c8b8f2fca7 /testapi/opnfv_testapi/resources/result_handlers.py
parentbba00ca773c4851de91ab19d34859b930b9e1960 (diff)
bugfix: query doesn't work well with period=1
when querying by date, if $lt is not provided, the empty/None/null/'' results will also be returned, the patch aims to fix this issue by adding $lt = datetime.now() if not provided JIRA: RELENG-212 Change-Id: Ida1e7d386a88d4ab640441df161c1fe134593f82 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/resources/result_handlers.py')
-rw-r--r--testapi/opnfv_testapi/resources/result_handlers.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/testapi/opnfv_testapi/resources/result_handlers.py b/testapi/opnfv_testapi/resources/result_handlers.py
index 1773216..57ad27e 100644
--- a/testapi/opnfv_testapi/resources/result_handlers.py
+++ b/testapi/opnfv_testapi/resources/result_handlers.py
@@ -60,6 +60,12 @@ class GenericResultHandler(handlers.GenericApiHandler):
query[k] = v
if date_range:
query['start_date'] = date_range
+
+ # if $lt is not provided,
+ # empty/None/null/'' start_date will also be returned
+ if 'start_date' in query and '$lt' not in query['start_date']:
+ query['start_date'].update({'$lt': str(datetime.now())})
+
return query