aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2022-09-29 16:38:27 +0530
committerArun Isaac2022-09-29 16:38:27 +0530
commit0c71c536e503b0d77d7bea057370c49ec00f5225 (patch)
tree590727d247f6829a1291f0c180cb55c5bcc08456
parente1d1331185c23aa95ef70eb92a084c402113578f (diff)
downloadgenenetwork2-0c71c536e503b0d77d7bea057370c49ec00f5225.tar.gz
Hard-limit the number of search results.
* wqflask/wqflask/gsearch.py (MAX_SEARCH_RESULTS): New constant. (GSearch.__init__): Hard-limit the number of search results to MAX_SEARCH_RESULTS.
-rw-r--r--wqflask/wqflask/gsearch.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/wqflask/wqflask/gsearch.py b/wqflask/wqflask/gsearch.py
index f2ee1826..ee1291be 100644
--- a/wqflask/wqflask/gsearch.py
+++ b/wqflask/wqflask/gsearch.py
@@ -10,6 +10,9 @@ from utility.authentication_tools import check_resource_availability
from utility.monads import MonadicDict
from wqflask.database import xapian_database
+# KLUDGE: Due to the lack of pagination, we hard-limit the maximum
+# number of search results.
+MAX_SEARCH_RESULTS = 1000
def is_permitted_for_listing(trait, search_type):
"""Check if it is permissible to list trait in search results."""
@@ -66,7 +69,7 @@ class GSearch:
query,
xapian.Query(f"XT{self.type}")))
for i, trait in enumerate(
- [trait for xapian_match in enquire.get_mset(0, db.get_doccount())
+ [trait for xapian_match in enquire.get_mset(0, MAX_SEARCH_RESULTS)
if is_permitted_for_listing(
trait := MonadicDict(json.loads(xapian_match.document.get_data())),
search_type=self.type)]):