diff options
author | Munyoki Kilyungi | 2023-01-16 16:50:51 +0300 |
---|---|---|
committer | BonfaceKilz | 2023-01-20 15:02:46 +0300 |
commit | 000880beabe2fe495f048669c37634d55cfc3610 (patch) | |
tree | f4f6ee610e945df05f6aeb483dba1087b3ab3aaa /scripts/sampledata.py | |
parent | 609fca7ec0908c9937a3c3bd3862cf166e71214e (diff) | |
download | genenetwork2-000880beabe2fe495f048669c37634d55cfc3610.tar.gz |
Add a function that fetches all the traits given the right params
* scripts/sampledata.py (fetch_all_traits): New function.
Diffstat (limited to 'scripts/sampledata.py')
-rw-r--r-- | scripts/sampledata.py | 13 |
1 files changed, 12 insertions, 1 deletions
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') |