From 9c0b4a7f5819642bb8f847837e14d904fb6e48a8 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Sun, 5 Apr 2020 16:37:35 -0600 Subject: [PATCH] Minor fix for filtering by time range --- app/routes.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/routes.py b/app/routes.py index ad436a4..58f722b 100644 --- a/app/routes.py +++ b/app/routes.py @@ -57,10 +57,16 @@ def search(): return render_template('error.html') # Use :past(hour/day/week/month/year) if available - # example search "new restaurants :pastmonth" + # example search "new restaurants :past month" tbs = '' + # if 'tbs' in request.args: + # tbs = '&tbs=' + request.args.get('tbs') + # q = q.replace(q.split(':past', 1)[-1], '').replace(':past', '') if ':past' in q: - tbs = '&tbs=qdr:' + str.lower(q.split(':past', 1)[-1][0]) + time_range = str.strip(q.split(':past', 1)[-1]) + tbs = '&tbs=qdr:' + str.lower(time_range[0]) + + # Ensure search query is parsable q = urlparse.quote(q) # Pass along type of results (news, images, books, etc)