viz: cache datetime.now() in query_obj (#955)

It shouldn't be a big deal, and it's pretty cheap on linux, but
still :)
This commit is contained in:
Riccardo Magliocchetti 2016-08-17 06:40:27 +02:00 committed by Maxime Beauchemin
parent 061d4f1ac7
commit cc058e5c9e
1 changed files with 3 additions and 2 deletions

View File

@ -224,8 +224,9 @@ class BaseViz(object):
form_data.get("row_limit", config.get("ROW_LIMIT")))
since = form_data.get("since", "1 year ago")
from_dttm = utils.parse_human_datetime(since)
if from_dttm > datetime.now():
from_dttm = datetime.now() - (from_dttm-datetime.now())
now = datetime.now()
if from_dttm > now:
from_dttm = now - (from_dttm - now)
until = form_data.get("until", "now")
to_dttm = utils.parse_human_datetime(until)
if from_dttm > to_dttm: