aboutsummaryrefslogtreecommitdiffstats
path: root/fatcat_scholar
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-08-06 13:56:36 -0700
committerBryan Newbold <bnewbold@archive.org>2020-08-06 13:56:36 -0700
commit3e33a40f7affc7fc524e7454bea9976186882a84 (patch)
tree2b811e306e0408ec7ea69c07ebc3db77a9806d86 /fatcat_scholar
parent570af878e5797e14e055b9a612d83b6263012802 (diff)
downloadfatcat-scholar-3e33a40f7affc7fc524e7454bea9976186882a84.tar.gz
fatcat-scholar-3e33a40f7affc7fc524e7454bea9976186882a84.zip
better time ranges (don't search future)
Diffstat (limited to 'fatcat_scholar')
-rw-r--r--fatcat_scholar/search.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index d4736d1..7558db1 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -126,13 +126,16 @@ def do_fulltext_search(
elif query.filter_time == "past_year":
# (date in the past year) or (year is this year)
# the later to catch papers which don't have release_date defined
- year_ago_date = str(datetime.date.today() - datetime.timedelta(days=365))
- this_year = datetime.date.today().year
+ date_today = datetime.date.today()
+ this_year = date_today.year
+ tomorrow_date = str(date_today + datetime.timedelta(days=1))
+ year_ago_date = str(date_today - datetime.timedelta(days=365))
search = search.filter(
- Q("range", date=dict(gte=year_ago_date)) | Q("term", year=this_year)
+ Q("range", date=dict(gte=year_ago_date, lte=tomorrow_date)) | Q("term", year=this_year)
)
elif query.filter_time == "since_2000":
- search = search.filter("range", year=dict(gte=2000))
+ this_year = datetime.date.today().year
+ search = search.filter("range", year=dict(gte=2000, lte=this_year))
elif query.filter_time == "before_1925":
search = search.filter("range", year=dict(lt=1925))
elif query.filter_time == "all_time" or query.filter_time is None: