Skip to content

Commit 44ccbe7

Browse files
committed
fix: [search] same date search filter
1 parent 9714d8e commit 44ccbe7

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

bin/lib/search_engine.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,9 @@ def api_search(data):
669669
return {"status": "error", "reason": "Invalid date from"}, 400
670670
if timestamp_to:
671671
try:
672-
timestamp_to = Date.convert_str_date_to_epoch(timestamp_to)
672+
timestamp_to = Date.convert_str_date_to_epoch_end(timestamp_to)
673673
except:
674-
return {"status": "error", "reason": "Invalid date from"}, 400
674+
return {"status": "error", "reason": "Invalid date to"}, 400
675675

676676
try:
677677
result = Engine.search(indexes, to_search, page=page, nb=nb_per_page, timestamp_from=timestamp_from, sort=sort,

bin/packages/Date.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ def convert_str_date_to_epoch(date_str):
1919
dt = datetime.datetime.strptime(date_str.replace('-', ''), "%Y%m%d").replace(tzinfo=datetime.timezone.utc)
2020
return int(dt.timestamp())
2121

22+
def convert_str_date_to_epoch_end(date_str):
23+
dt = datetime.datetime.strptime(date_str.replace('-', ''), "%Y%m%d").replace(tzinfo=datetime.timezone.utc)
24+
dt = dt + datetime.timedelta(days=1, seconds=-1)
25+
return int(dt.timestamp())
26+
2227
def get_full_month_str(date_from, date_to):
2328
# add one day (if last day of the month)
2429
date_to = date_to + relativedelta(days=+1)

var/www/templates/search/search_dashboard.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ <h6 class="text-uppercase text-muted mb-3">Search scope</h6>
400400

401401
</div>
402402

403-
<div class="collapse mt-2 {% if request.args.get('from') or request.args.get('to') or selected_forums %}show{% endif %}" id="moreFilters">
403+
<div class="collapse mt-2 {% if request.args.get('from') or request.args.get('to') %}show{% endif %}" id="moreFilters">
404404
<div class="card card-body">
405405

406406
<div class="form-row align-items-end">
407407
<div class="col-md-4">
408-
<label class="small text-muted mb-1" for="last_seen_from">Last seen (from)</label>
408+
<label class="small text-muted mb-1" for="last_seen_from">First seen (from)</label>
409409
<input type="date" class="form-control"
410410
id="last_seen_from"
411411
name="from"

0 commit comments

Comments
 (0)