From 29ff1b6b7b00b34317e8d9764bcedd5b7dacbc02 Mon Sep 17 00:00:00 2001
From: John Nduli
Date: Fri, 30 Aug 2024 12:19:50 +0300
Subject: feat: add ai search box to xapian results page
---
gn2/wqflask/templates/gsearch_gene.html | 26 ++++++++++++++++++++------
gn2/wqflask/views.py | 14 ++++++++++----
2 files changed, 30 insertions(+), 10 deletions(-)
diff --git a/gn2/wqflask/templates/gsearch_gene.html b/gn2/wqflask/templates/gsearch_gene.html
index 3432662d..c32f1ee1 100644
--- a/gn2/wqflask/templates/gsearch_gene.html
+++ b/gn2/wqflask/templates/gsearch_gene.html
@@ -10,12 +10,26 @@
-
GN searched for the term(s) "{{ terms }}" in 754 datasets and 39,765,944 traits across 10 species
- and found {{ trait_count }} results that match your query.
- You can filter these results by adding key words in the fields below
- and you can also sort results on most columns.
-
To study a record, click on its Record ID below. Check records below and click Add button to add to selection.
-
+
+
+
GN searched for the term(s) "{{ terms }}" in 754 datasets and 39,765,944 traits across 10 species
+ and found {{ trait_count }} results that match your query.
+ You can filter these results by adding key words in the fields below
+ and you can also sort results on most columns.
+
To study a record, click on its Record ID below. Check records below and click Add button to add to selection.
diff --git a/gn2/wqflask/views.py b/gn2/wqflask/views.py
index ec252cab..5b83bb82 100644
--- a/gn2/wqflask/views.py
+++ b/gn2/wqflask/views.py
@@ -242,10 +242,16 @@ def search_page_table():
@app.route("/gsearch", methods=('GET',))
def gsearchact():
result = GSearch(request.args).__dict__
- type = request.args['type']
- if type == "gene":
- return render_template("gsearch_gene.html", **result)
- elif type == "phenotype":
+ search_type = request.args['type']
+ ai_result = {
+ "search_term": "which animal has the same number of chromosomes as human",
+ "search_result": "The Bama miniature pig has the same number of chromosomes as humans",
+ # we need to modify the search to use url params so that we can easily link
+ "search_url": "https://qa.genenetwork.org/gnqna"
+ }
+ if search_type == "gene":
+ return render_template("gsearch_gene.html", **result, ai_result=ai_result)
+ elif search_type == "phenotype":
return render_template("gsearch_pheno.html", **result)
--
cgit v1.2.3