2018-08-22 00:15:29 +08:00
|
|
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
|
|
|
-- 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
|
|
|
|
|
2018-08-22 00:18:10 +08:00
|
|
|
-- 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;
|