aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
authorAlexander Kabui2021-10-22 15:26:20 +0300
committerBonfaceKilz2021-11-04 15:22:13 +0300
commitc83dc9f45d6df6faa7d95916a998ded9be3167fa (patch)
treea0e1f6b242f32785f9de36a188edde55c30310a0 /wqflask
parent678127848128b5ded02df501b60c8edb4d036d76 (diff)
downloadgenenetwork2-c83dc9f45d6df6faa7d95916a998ded9be3167fa.tar.gz
fetch cached results
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/base/data_set.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py
index 8188d90c..51244303 100644
--- a/wqflask/base/data_set.py
+++ b/wqflask/base/data_set.py
@@ -1243,7 +1243,7 @@ def geno_mrna_confidentiality(ob):
return True
-def check_if_dataset_modified(dataset_name, cached_timestamp):
+def check_if_dataset_modified(dataset_name: str, cached_timestamp):
"""function to check if the dataset has been modified"""
last_modified = "query results"
return (cached_timestamp == last_modified_timestamp)
@@ -1264,4 +1264,18 @@ def cache_dataset_results(dataset_name: str, query_results: List):
query_results = [list(results) for result in query_results]
with open(file_path, "w") as file_handler:
- json.dump(query_results, file_handler) \ No newline at end of file
+ json.dump(query_results, file_handler)
+
+def fetch_cached_results(dataset_name: str):
+ """function to fetch the cached results"""
+ file_path = os.path.join(TMPDIR, f"{dataset_name}.json")
+
+ try:
+ with open(file_path) as file_handler:
+ data = json.load(file_handler)
+ # check if table has been modified
+ if check_if_dataset_modified(dataset_name["timestamp"]):
+ return data[dataset_name]
+ except FileNotFoundError:
+ # take actions continue to fetch dataset results and fetch results
+ pass \ No newline at end of file