From db986d8524d8befa075b213c81168f7102c78b56 Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Wed, 19 Jul 2017 13:29:53 +0800 Subject: 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 --- utils/test/testapi/opnfv_testapi/resources/result_handlers.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'utils/test/testapi/opnfv_testapi/resources/result_handlers.py') diff --git a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py b/utils/test/testapi/opnfv_testapi/resources/result_handlers.py index 1773216c0..57ad27e6e 100644 --- a/utils/test/testapi/opnfv_testapi/resources/result_handlers.py +++ b/utils/test/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 -- cgit 1.2.3-korg