aboutsummaryrefslogtreecommitdiff
path: root/wqflask/base/data_set/probably_unused.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-20 11:40:56 +0300
committerFrederick Muriuki Muriithi2022-09-20 11:50:32 +0300
commit8f732461b897a7c229c3b49a74fd831c2e440989 (patch)
tree769f044294c118eb3aec631d3d26485b4280637e /wqflask/base/data_set/probably_unused.py
parentce07180fbc07fbf61d4dc26bf5d20cdf6f7df91f (diff)
downloadgenenetwork2-8f732461b897a7c229c3b49a74fd831c2e440989.tar.gz
Decompose file into separate modulesrefactor-data_set_py-20220920
To ease future refactors on the code, decompose the file into a module with multiple modules that can be refactored semi-independently.
Diffstat (limited to 'wqflask/base/data_set/probably_unused.py')
-rw-r--r--wqflask/base/data_set/probably_unused.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/wqflask/base/data_set/probably_unused.py b/wqflask/base/data_set/probably_unused.py
new file mode 100644
index 00000000..4e54bcff
--- /dev/null
+++ b/wqflask/base/data_set/probably_unused.py
@@ -0,0 +1,34 @@
+"Functions that are probably unused in the code"
+
+import pickle as pickle
+
+from wqflask.database import database_connection
+
+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() 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