make "before" and "after" human-readable

remotes/1693045480750635534/spooky-22
Aevann1 2022-08-17 21:09:15 +02:00
parent 7afdcb83b0
commit 1d7b19f485
3 changed files with 20 additions and 16 deletions

View File

@ -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)

View File

@ -90,17 +90,19 @@
</a>
</div>
{% endif %}
<div class="flex-grow-1 d-fl d-none d-md-block {% if not v %}pad{% endif %}">
<form class="form-inline search flex-nowrap mx-0 mx-lg-auto" {% if err %}style="margin-right:40rem!important"{% endif %} action="{% if request.path.startswith('/search') %}{{request.path}}{% else %}/search/posts/{% endif %}" method="get">
<input autocomplete="off" class="form-control w-100" type="search" placeholder="{{search_placeholder}}" aria-label="Search" name="q" value="{{request.values.get('q', '')}}">
<span class="input-group-append">
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem;">
<i class="fa fa-search" aria-hidden="true"></i>
{% if not request.path.startswith('/search/') %}
<div class="flex-grow-1 d-fl d-none d-md-block {% if not v %}pad{% endif %}">
<form class="form-inline search flex-nowrap mx-0 mx-lg-auto" {% if err %}style="margin-right:40rem!important"{% endif %} action="{% if request.path.startswith('/search') %}{{request.path}}{% else %}/search/posts/{% endif %}" method="get">
<input autocomplete="off" class="form-control w-100" type="search" placeholder="{{search_placeholder}}" aria-label="Search" name="q" value="{{request.values.get('q', '')}}">
<span class="input-group-append">
<span class="input-group-text border-0 bg-transparent" style="margin-left: -2.5rem;">
<i class="fa fa-search" aria-hidden="true"></i>
</span>
</span>
</span>
</form>
</div>
</form>
</div>
{% endif %}
{% if g.webview %}
<a class="mobile-nav-icon d-md-none" onclick="location.reload()"><i class="fas fa-arrow-rotate-right align-middle text-gray-500 black"></i></a>

View File

@ -43,8 +43,8 @@
<li class="mb-1">domain:reddit.com</li>
<li class="mb-1">over18:true</li>
<li class="mb-1">{{HOLE_NAME}}:music</li>
<li class="mb-1">before:1660590018</li>
<li class="mb-1">after:1660590018</li>
<li class="mb-1">before:2022-12-30</li>
<li class="mb-1">after:2022-12-30</li>
{% if request.path.startswith('/search/comments') %}
<li class="mb-1">post:504</li>
{% endif %}