summaryrefslogtreecommitdiffstats
path: root/fatcat_scholar/search.py
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-06-03 23:16:07 -0700
committerBryan Newbold <bnewbold@archive.org>2020-06-03 23:16:07 -0700
commit62fde540ef9c38d403ea89a6fb1db51bfba23da8 (patch)
tree2142c739349237b0ef137a57000850db1b2ff39d /fatcat_scholar/search.py
parent74ef1c6f4e0f08dd6a6b3e6eacc4d780c990eb3f (diff)
downloadfatcat-scholar-62fde540ef9c38d403ea89a6fb1db51bfba23da8.tar.gz
fatcat-scholar-62fde540ef9c38d403ea89a6fb1db51bfba23da8.zip
flake8 fixes (partial)
Diffstat (limited to 'fatcat_scholar/search.py')
-rw-r--r--fatcat_scholar/search.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/fatcat_scholar/search.py b/fatcat_scholar/search.py
index 5a61f53..3d9ca9b 100644
--- a/fatcat_scholar/search.py
+++ b/fatcat_scholar/search.py
@@ -3,15 +3,13 @@ Helpers to make elasticsearch queries.
"""
import sys
-import json
from gettext import gettext
import datetime
import elasticsearch
from pydantic import BaseModel
from dynaconf import settings
-from dataclasses import dataclass
from elasticsearch_dsl import Search, Q
-from typing import List, Dict, Tuple, Optional, Any, Sequence
+from typing import List, Optional, Any
# i18n note: the use of gettext below doesn't actually do the translation here,
# it just ensures that the strings are caught by babel for translation later
@@ -106,7 +104,7 @@ def do_fulltext_search(
search = search.filter("terms", type=["report", "standard",])
elif query.filter_type == "datasets":
search = search.filter("terms", type=["dataset", "software",])
- elif query.filter_type == "everything" or query.filter_type == None:
+ elif query.filter_type == "everything" or query.filter_type is None:
pass
else:
raise ValueError(
@@ -129,7 +127,7 @@ def do_fulltext_search(
search = search.filter("range", year=dict(gte=2000))
elif query.filter_time == "before_1925":
search = search.filter("range", year=dict(lt=1925))
- elif query.filter_time == "all_time" or query.filter_time == None:
+ elif query.filter_time == "all_time" or query.filter_time is None:
pass
else:
raise ValueError(
@@ -141,7 +139,7 @@ def do_fulltext_search(
search = search.filter("term", tag="oa")
elif query.filter_availability == "everything":
pass
- elif query.filter_availability == "fulltext" or query.filter_availability == None:
+ elif query.filter_availability == "fulltext" or query.filter_availability is None:
search = search.filter("terms", access_type=["wayback", "ia_file", "ia_sim"])
else:
raise ValueError(
@@ -199,7 +197,7 @@ def do_fulltext_search(
search = search.sort("year", "date")
elif query.sort_order == "time_desc":
search = search.sort("-year", "-date")
- elif query.sort_order == "relevancy" or query.sort_order == None:
+ elif query.sort_order == "relevancy" or query.sort_order is None:
pass
else:
raise ValueError(f"Unknown 'sort_order' parameter value: '{query.sort_order}'")
@@ -211,7 +209,7 @@ def do_fulltext_search(
# Avoid deep paging problem.
offset = deep_page_limit
- search = search[offset : offset + limit]
+ search = search[offset:(offset+limit)]
try:
resp = search.execute()