diff options
author | Alexander_Kabui | 2024-01-02 13:21:07 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-01-02 13:21:07 +0300 |
commit | 70c4201b332e0e2c0d958428086512f291469b87 (patch) | |
tree | aea4fac8782c110fc233c589c3f0f7bd34bada6c /gn2/base/data_set/probably_unused.py | |
parent | 5092eb42f062b1695c4e39619f0bd74a876cfac2 (diff) | |
parent | 965ce5114d585624d5edb082c710b83d83a3be40 (diff) | |
download | genenetwork2-70c4201b332e0e2c0d958428086512f291469b87.tar.gz |
merge changes
Diffstat (limited to 'gn2/base/data_set/probably_unused.py')
-rw-r--r-- | gn2/base/data_set/probably_unused.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gn2/base/data_set/probably_unused.py b/gn2/base/data_set/probably_unused.py new file mode 100644 index 00000000..12be05a7 --- /dev/null +++ b/gn2/base/data_set/probably_unused.py @@ -0,0 +1,35 @@ +"Functions that are probably unused in the code" + +import pickle as pickle + +from gn2.wqflask.database import database_connection +from gn2.utility.tools import get_setting + +def create_datasets_list(): + if USE_REDIS: + key = "all_datasets" + result = redis_conn.get(key) + + if result: + datasets = pickle.loads(result) + + if result is None: + datasets = list() + type_dict = {'Publish': 'PublishFreeze', + 'ProbeSet': 'ProbeSetFreeze', + 'Geno': 'GenoFreeze'} + + for dataset_type in type_dict: + with database_connection(get_setting("SQL_URI")) as conn, conn.cursor() as cursor: + cursor.execute("SELECT Name FROM %s", + (type_dict[dataset_type],)) + results = cursor.fetchall(query) + if results: + for result in results: + datasets.append( + create_dataset(result.Name, dataset_type)) + if USE_REDIS: + redis_conn.set(key, pickle.dumps(datasets, pickle.HIGHEST_PROTOCOL)) + redis_conn.expire(key, 60 * 60) + + return datasets |