From 65ac5dec591f905cb181354fbf870b9439d28109 Mon Sep 17 00:00:00 2001 From: Christian Quest Date: Mon, 30 May 2016 07:34:58 +0200 Subject: [PATCH] when=today/tomorrow/yesterday search added --- backend.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend.py b/backend.py index 23063cc..0e9b11a 100644 --- a/backend.py +++ b/backend.py @@ -123,7 +123,15 @@ class EventResource(BaseEvent): if 'when' in req.params: # limit search with fixed time - event_when = cur.mogrify("tstzrange(%s,%s,'[]')", (req.params['when'], req.params['when'])).decode("utf-8") + when = req.params['when'] + if when == 'TODAY': + event_when = "tstzrange(CURRENT_DATE,CURRENT_DATE + INTERVAL '1 DAY','[]')" + elif when == 'TOMORROW': + event_when = "tstzrange(CURRENT_DATE + INTERVAL '1 DAY',CURRENT_DATE + INTERVAL '2 DAY','[]')" + elif when == 'YESTERDAY': + event_when = "tstzrange(CURRENT_DATE - INTERVAL '1 DAY',CURRENT_DATE,'[]')" + else: + event_when = cur.mogrify("tstzrange(%s,%s,'[]')", (when, when)).decode("utf-8") elif 'start' in req.params and 'stop' in req.params: # limit search with fixed time (start to stop) event_when = cur.mogrify("tstzrange(%s,%s,'[]')", (req.params['start'], req.params['stop'])).decode("utf-8")