From 65c0d507d1b2fb89826225fe572356647f335512 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 28 May 2020 17:31:09 -0500 Subject: Add redis functions for querying redis --- wqflask/utility/redis_tools.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wqflask/utility/redis_tools.py b/wqflask/utility/redis_tools.py index ca42f7b7..3db37223 100644 --- a/wqflask/utility/redis_tools.py +++ b/wqflask/utility/redis_tools.py @@ -28,6 +28,20 @@ def get_user_id(column_name, column_value): return None +def get_resource_id_by_data(res_type, res_data): + resource_list = Redis.hgetall("resources") + for key in resource_list: + resource_ob = json.loads(resource_list[key]) + + logger.info(resource_ob["data"]) + if resource_ob["type"] == res_type and resource_ob["data"] == res_data: + return key + + return None + +def get_resource(resource_id): + return json.loads(Redis.hget("resources", resource_id)) + def get_user_by_unique_column(column_name, column_value): item_details = None @@ -167,4 +181,4 @@ def change_group_name(user_id, group_id, new_name): group_info["name"] = new_name return group_info else: - return None \ No newline at end of file + return None -- cgit v1.2.3