From 33860b0cb274dc41077c71efad78da39d3830764 Mon Sep 17 00:00:00 2001
From: zsloan
Date: Thu, 24 Aug 2023 19:27:40 +0000
Subject: Change inputs for pheno sample data CSV function + only fetch sample
data for table when fewer than 2000 samples
---
wqflask/wqflask/metadata_edits.py | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index c242e9b1..87d98160 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -119,7 +119,9 @@ def display_phenotype_metadata(dataset_id: str, name: str):
group_name = retrieve_phenotype_group_name(conn, dataset_id)
sample_list = retrieve_sample_list(group_name)
- sample_data = get_pheno_sample_data(conn, name, _d["publish_xref"]["phenotype_id"])
+ sample_data = []
+ if len(sample_list) < 2000:
+ sample_data = get_pheno_sample_data(conn, name, _d["publish_xref"]["phenotype_id"])
return render_template(
"edit_phenotype.html",
@@ -194,8 +196,8 @@ def update_phenotype(dataset_id: str, name: str):
headers = ["Strain Name", "Value", "SE", "Count"]
base_csv = get_pheno_csv_sample_data(
conn=conn,
- trait_name=str(name),
- phenotype_id=str(phenotype_id),
+ trait_name=name,
+ group_id=dataset_id,
sample_list=sample_list,
)
if not (file_) and data_.get('edited') == "true":
@@ -578,23 +580,23 @@ View the diffs here", "success")
)
-@metadata_edit.route("/pheno//traits//csv")
+@metadata_edit.route("/pheno//group//csv")
@login_required()
-def get_pheno_sample_data_as_csv(dataset_id: str, phenotype_id: int):
+def get_pheno_sample_data_as_csv(name: int, group_id: int):
from utility.tools import get_setting
with database_connection(get_setting("SQL_URI")) as conn:
+ group_name = retrieve_phenotype_group_name(conn, group_id)
return Response(
get_pheno_csv_sample_data(
conn=conn,
- trait_name=str(dataset_id),
- phenotype_id=str(phenotype_id),
- sample_list=retrieve_sample_list(
- retrieve_phenotype_group_name(conn, dataset_id))
+ trait_name=name,
+ group_id=group_id,
+ sample_list=retrieve_sample_list(group_name)
),
mimetype="text/csv",
headers={
"Content-disposition": f"attachment; \
-filename=sample-data-{dataset_id}.csv"
+filename=sample-data-{group_name}-{name}.csv"
},
)
--
cgit v1.2.3