From 1d7b19f48543b57b30b781874d32fc1bd70aacaf Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 17 Aug 2022 21:09:15 +0200 Subject: [PATCH] make "before" and "after" human-readable --- files/routes/search.py | 10 ++++++---- files/templates/header.html | 22 ++++++++++++---------- files/templates/search.html | 4 ++-- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/files/routes/search.py b/files/routes/search.py index 8f70983a2..80982b436 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -5,6 +5,8 @@ from flask import * from files.__main__ import app from files.helpers.regex import * from files.helpers.sorting_and_time import * +import time +from calendar import timegm search_operator_hole = HOLE_NAME @@ -119,11 +121,11 @@ def searchposts(v): posts = posts.filter(Submission.sub == criteria[search_operator_hole]) if 'after' in criteria: - after = int(criteria['after']) + after = timegm(time.strptime(criteria['after'], "%Y-%m-%d")) posts = posts.filter(Submission.created_utc > after) if 'before' in criteria: - before = int(criteria['before']) + before = timegm(time.strptime(criteria['before'], "%Y-%m-%d")) posts = posts.filter(Submission.created_utc < before) posts = apply_time_filter(t, posts, Submission) @@ -216,11 +218,11 @@ def searchcomments(v): comments = comments.filter(Comment.parent_submission.notin_(club)) if 'after' in criteria: - after = int(criteria['after']) + after = timegm(time.strptime(criteria['after'], "%Y-%m-%d")) comments = comments.filter(Comment.created_utc > after) if 'before' in criteria: - before = int(criteria['before']) + before = timegm(time.strptime(criteria['before'], "%Y-%m-%d")) comments = comments.filter(Comment.created_utc < before) comments = sort_comments(sort, comments) diff --git a/files/templates/header.html b/files/templates/header.html index 08b50a389..d0ee14cd8 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -90,17 +90,19 @@ {% endif %} - -
-
+ {% endif %} {% if g.webview %} diff --git a/files/templates/search.html b/files/templates/search.html index 22a052868..eec44780b 100644 --- a/files/templates/search.html +++ b/files/templates/search.html @@ -43,8 +43,8 @@
  • domain:reddit.com
  • over18:true
  • {{HOLE_NAME}}:music
  • -
  • before:1660590018
  • -
  • after:1660590018
  • +
  • before:2022-12-30
  • +
  • after:2022-12-30
  • {% if request.path.startswith('/search/comments') %}
  • post:504
  • {% endif %}