From b21cbe1d46978413f3decb2332f670294ca76708 Mon Sep 17 00:00:00 2001 From: Christian Quest Date: Sun, 8 May 2016 14:43:41 +0200 Subject: [PATCH] start/stop to now by default --- backend.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend.py b/backend.py index 98c1dd6..a60d8ac 100644 --- a/backend.py +++ b/backend.py @@ -84,8 +84,14 @@ class EventResource(object): # limit search with fixed time event_when = cur.mogrify("tstzrange(%s,%s,'[]')",(req.params['when'],req.params['when'])).decode("utf-8") elif 'start' in req.params and 'stop' in req.params: - # limit search with fixed time + # limit search with fixed time (start to stop) event_when = cur.mogrify("tstzrange(%s,%s,'[]')",(req.params['start'],req.params['stop'])).decode("utf-8") + elif 'start' in req.params and 'stop' not in req.params: + # limit search with fixed time (start to now) + event_when = cur.mogrify("tstzrange(%s,now(),'[]')",(req.params['start'],)).decode("utf-8") + elif 'start' not in req.params and 'stop' in req.params: + # limit search with fixed time (now to stop) + event_when = cur.mogrify("tstzrange(now(),%s,'[]')",(req.params['stop'],)).decode("utf-8") else: event_when = """tstzrange(now(),now(),'[]')"""