From 000880beabe2fe495f048669c37634d55cfc3610 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 16 Jan 2023 16:50:51 +0300 Subject: Add a function that fetches all the traits given the right params * scripts/sampledata.py (fetch_all_traits): New function. --- scripts/sampledata.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/sampledata.py b/scripts/sampledata.py index e1b38f3c..fb3668d6 100644 --- a/scripts/sampledata.py +++ b/scripts/sampledata.py @@ -6,6 +6,7 @@ from wqflask import app from wqflask.show_trait import show_trait from wqflask.database import database_connection +from wqflask.search_results import SearchResultPage class UserSessionSimulator(): @@ -47,4 +48,14 @@ def dump_sample_data(dataset_name, trait_id): return sample_data -print(json.dumps(dump_sample_data("BXDPublish", "10007"))) +def fetch_all_traits(species, group, type_, dataset): + with app.app_context(): + g.user_session = UserSessionSimulator(None) + for result in SearchResultPage({ + "species": species, + "group": group, + "type": type_, + "dataset": dataset, + "search_terms_or": "*", + }).trait_list: + yield result.get('name') -- cgit v1.2.3