diff --git a/server/extension/cdb_dataservices_server--0.32.0--0.33.0.sql b/server/extension/cdb_dataservices_server--0.32.0--0.33.0.sql index 0494d33..ff9f166 100644 --- a/server/extension/cdb_dataservices_server--0.32.0--0.33.0.sql +++ b/server/extension/cdb_dataservices_server--0.32.0--0.33.0.sql @@ -2,4 +2,5 @@ -- Complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "ALTER EXTENSION cdb_dataservices_server UPDATE TO '0.33.0'" to load this file. \quit --- HERE goes your code to upgrade/downgrade \ No newline at end of file +-- HERE goes your code to upgrade/downgrade +DROP FUNCTION IF EXISTS cdb_dataservices_server._get_obs_snapshot_config; diff --git a/server/extension/cdb_dataservices_server--0.33.0--0.32.0.sql b/server/extension/cdb_dataservices_server--0.33.0--0.32.0.sql index 7da98ea..1e883ec 100644 --- a/server/extension/cdb_dataservices_server--0.33.0--0.32.0.sql +++ b/server/extension/cdb_dataservices_server--0.33.0--0.32.0.sql @@ -2,4 +2,17 @@ -- Complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "ALTER EXTENSION cdb_dataservices_server UPDATE TO '0.32.0'" to load this file. \quit --- HERE goes your code to upgrade/downgrade \ No newline at end of file +-- HERE goes your code to upgrade/downgrade +CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_obs_snapshot_config(username text, orgname text) +RETURNS boolean AS $$ + cache_key = "user_obs_snapshot_config_{0}".format(username) + if cache_key in GD: + return False + else: + from cartodb_services.metrics import ObservatorySnapshotConfig + plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) + redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection'] + obs_snapshot_config = ObservatorySnapshotConfig(redis_conn, plpy, username, orgname) + GD[cache_key] = obs_snapshot_config + return True +$$ LANGUAGE plpythonu SECURITY DEFINER STABLE PARALLEL RESTRICTED; diff --git a/server/extension/sql/15_config_helper.sql b/server/extension/sql/15_config_helper.sql index 31d3331..6e4d884 100644 --- a/server/extension/sql/15_config_helper.sql +++ b/server/extension/sql/15_config_helper.sql @@ -90,20 +90,6 @@ RETURNS boolean AS $$ return True $$ LANGUAGE plpythonu SECURITY DEFINER; -CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_obs_snapshot_config(username text, orgname text) -RETURNS boolean AS $$ - cache_key = "user_obs_snapshot_config_{0}".format(username) - if cache_key in GD: - return False - else: - from cartodb_services.metrics import ObservatorySnapshotConfig - plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) - redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection'] - obs_snapshot_config = ObservatorySnapshotConfig(redis_conn, plpy, username, orgname) - GD[cache_key] = obs_snapshot_config - return True -$$ LANGUAGE plpythonu SECURITY DEFINER STABLE PARALLEL RESTRICTED; - CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_obs_config(username text, orgname text) RETURNS boolean AS $$ cache_key = "user_obs_config_{0}".format(username)