forked from rDrama/rDrama
add "before" and "after" search keywords
parent
5d39c9dfbb
commit
133508fc6a
|
@ -13,6 +13,8 @@ valid_params = [
|
||||||
'domain',
|
'domain',
|
||||||
'over18',
|
'over18',
|
||||||
"post",
|
"post",
|
||||||
|
"before",
|
||||||
|
"after",
|
||||||
search_operator_hole,
|
search_operator_hole,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -116,6 +118,14 @@ def searchposts(v):
|
||||||
if search_operator_hole in criteria:
|
if search_operator_hole in criteria:
|
||||||
posts = posts.filter(Submission.sub == criteria[search_operator_hole])
|
posts = posts.filter(Submission.sub == criteria[search_operator_hole])
|
||||||
|
|
||||||
|
if 'after' in criteria:
|
||||||
|
after = int(criteria['after'])
|
||||||
|
posts = posts.filter(Submission.created_utc > after)
|
||||||
|
|
||||||
|
if 'before' in criteria:
|
||||||
|
before = int(criteria['before'])
|
||||||
|
posts = posts.filter(Submission.created_utc < before)
|
||||||
|
|
||||||
posts = apply_time_filter(t, posts, Submission)
|
posts = apply_time_filter(t, posts, Submission)
|
||||||
|
|
||||||
posts = sort_posts(sort, posts)
|
posts = sort_posts(sort, posts)
|
||||||
|
@ -205,6 +215,13 @@ def searchcomments(v):
|
||||||
club = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
club = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
||||||
comments = comments.filter(Comment.parent_submission.notin_(club))
|
comments = comments.filter(Comment.parent_submission.notin_(club))
|
||||||
|
|
||||||
|
if 'after' in criteria:
|
||||||
|
after = int(criteria['after'])
|
||||||
|
comments = comments.filter(Comment.created_utc > after)
|
||||||
|
|
||||||
|
if 'before' in criteria:
|
||||||
|
before = int(criteria['before'])
|
||||||
|
comments = comments.filter(Comment.created_utc < before)
|
||||||
|
|
||||||
comments = sort_comments(sort, comments)
|
comments = sort_comments(sort, comments)
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,8 @@
|
||||||
<li class="mb-1">domain:reddit.com</li>
|
<li class="mb-1">domain:reddit.com</li>
|
||||||
<li class="mb-1">over18:true</li>
|
<li class="mb-1">over18:true</li>
|
||||||
<li class="mb-1">{{HOLE_NAME}}:music</li>
|
<li class="mb-1">{{HOLE_NAME}}:music</li>
|
||||||
|
<li class="mb-1">before:1660590018</li>
|
||||||
|
<li class="mb-1">after:1660590018</li>
|
||||||
{% if request.path.startswith('/search/comments') %}
|
{% if request.path.startswith('/search/comments') %}
|
||||||
<li class="mb-1">post:504</li>
|
<li class="mb-1">post:504</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue