diff options
author | Alexander Kabui | 2021-10-26 12:54:15 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-11-04 15:22:13 +0300 |
commit | 09c1d0a93673965ffcf0fd93deff9b6ba5b84690 (patch) | |
tree | ca9457314e0165fb772c98c7057eae52a9045ed3 /wqflask/base | |
parent | 61d94ec99d0cfd1cb3a77d64629479d978e833e1 (diff) | |
download | genenetwork2-09c1d0a93673965ffcf0fd93deff9b6ba5b84690.tar.gz |
init function to get the table timestamp
Diffstat (limited to 'wqflask/base')
-rw-r--r-- | wqflask/base/data_set.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/wqflask/base/data_set.py b/wqflask/base/data_set.py index 1a208050..131702b8 100644 --- a/wqflask/base/data_set.py +++ b/wqflask/base/data_set.py @@ -1255,6 +1255,21 @@ def geno_mrna_confidentiality(ob): return True +def query_table_timestamp(dataset_type: str): + """function to query the update timestamp of a given dataset_type""" + + # computation data and actions + + query_update_time = """ + SELECT UPDATE_TIME FROM information_schema.tables + WHERE TABLE_SCHEMA = 'db_webqtl' + AND TABLE_NAME = 'ProbeSetData' + """ + + # store the timestamp in redis + return g.db.execute(query_update_time).fetchone() + + def generate_hash_file(dataset_name: str, dataset_timestamp: str): """given the trait_name generate a unique name for this""" @@ -1268,7 +1283,6 @@ def cache_dataset_results(dataset_name: str, dataset_timestamp: str, query_resul # data computations actions # store the file path on redis - file_name = generate_hash_file(dataset_name, dataset_timestamp) file_path = os.path.join(TMPDIR, f"{file_name}.json") @@ -1285,10 +1299,8 @@ def fetch_cached_results(dataset_name: str): file_path = os.path.join(TMPDIR, f"{file_name}.json") try: with open(file_path, "r") as file_handler: - data = json.load(file_handler) - # print(file_handler) - # check if table has been modified - return data + + return json.load(file_handler) except FileNotFoundError: # take actions continue to fetch dataset results and fetch results pass |