2016-08-03 23:37:40 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_logger_config()
|
|
|
|
RETURNS boolean AS $$
|
|
|
|
cache_key = "logger_config"
|
|
|
|
if cache_key in GD:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
from cartodb_services.tools import LoggerConfig
|
|
|
|
logger_config = LoggerConfig(plpy)
|
|
|
|
GD[cache_key] = logger_config
|
|
|
|
return True
|
2020-02-24 23:12:27 +08:00
|
|
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
2016-08-03 23:37:40 +08:00
|
|
|
|
2016-09-29 00:22:51 +08:00
|
|
|
-- This is done in order to avoid an undesired depedency on cartodb extension
|
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_conf_getconf(input_key text)
|
|
|
|
RETURNS JSON AS $$
|
|
|
|
SELECT VALUE FROM cartodb.cdb_conf WHERE key = input_key;
|
2017-11-08 00:23:05 +08:00
|
|
|
$$ LANGUAGE SQL SECURITY DEFINER STABLE PARALLEL SAFE;
|
2016-09-29 00:22:51 +08:00
|
|
|
|
2017-03-17 02:12:39 +08:00
|
|
|
CREATE OR REPLACE
|
2017-03-21 23:17:39 +08:00
|
|
|
FUNCTION cdb_dataservices_server.CDB_Conf_SetConf(key text, value JSON)
|
2017-03-17 02:12:39 +08:00
|
|
|
RETURNS void AS $$
|
|
|
|
BEGIN
|
2017-03-31 00:03:45 +08:00
|
|
|
PERFORM cdb_dataservices_server.CDB_Conf_RemoveConf(key);
|
2017-03-17 02:12:39 +08:00
|
|
|
EXECUTE 'INSERT INTO cartodb.CDB_CONF (KEY, VALUE) VALUES ($1, $2);' USING key, value;
|
|
|
|
END
|
2017-11-08 00:23:05 +08:00
|
|
|
$$ LANGUAGE PLPGSQL SECURITY DEFINER VOLATILE PARALLEL UNSAFE;
|
2017-03-17 02:12:39 +08:00
|
|
|
|
|
|
|
CREATE OR REPLACE
|
2017-03-21 23:17:39 +08:00
|
|
|
FUNCTION cdb_dataservices_server.CDB_Conf_RemoveConf(key text)
|
2017-03-17 02:12:39 +08:00
|
|
|
RETURNS void AS $$
|
|
|
|
BEGIN
|
|
|
|
EXECUTE 'DELETE FROM cartodb.CDB_CONF WHERE KEY = $1;' USING key;
|
|
|
|
END
|
2017-11-08 00:23:05 +08:00
|
|
|
$$ LANGUAGE PLPGSQL SECURITY DEFINER VOLATILE PARALLEL UNSAFE ;
|
2017-03-17 02:12:39 +08:00
|
|
|
|
|
|
|
|
2016-08-25 22:03:04 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_geocoder_config(username text, orgname text, provider text DEFAULT NULL)
|
2016-03-08 19:24:27 +08:00
|
|
|
RETURNS boolean AS $$
|
|
|
|
cache_key = "user_geocoder_config_{0}".format(username)
|
|
|
|
if cache_key in GD:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
from cartodb_services.metrics import GeocoderConfig
|
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection']
|
2016-08-25 22:03:04 +08:00
|
|
|
geocoder_config = GeocoderConfig(redis_conn, plpy, username, orgname, provider)
|
2016-03-08 19:24:27 +08:00
|
|
|
GD[cache_key] = geocoder_config
|
|
|
|
return True
|
2020-02-24 23:12:27 +08:00
|
|
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
2016-03-08 19:24:27 +08:00
|
|
|
|
2016-03-17 18:48:25 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_internal_geocoder_config(username text, orgname text)
|
|
|
|
RETURNS boolean AS $$
|
|
|
|
cache_key = "user_internal_geocoder_config_{0}".format(username)
|
|
|
|
if cache_key in GD:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
from cartodb_services.metrics import InternalGeocoderConfig
|
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection']
|
|
|
|
geocoder_config = InternalGeocoderConfig(redis_conn, plpy, username, orgname)
|
|
|
|
GD[cache_key] = geocoder_config
|
|
|
|
return True
|
2020-02-24 23:12:27 +08:00
|
|
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
2016-03-17 18:48:25 +08:00
|
|
|
|
2016-03-08 19:24:27 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_isolines_routing_config(username text, orgname text)
|
|
|
|
RETURNS boolean AS $$
|
|
|
|
cache_key = "user_isolines_routing_config_{0}".format(username)
|
|
|
|
if cache_key in GD:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
from cartodb_services.metrics import IsolinesRoutingConfig
|
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection']
|
|
|
|
isolines_routing_config = IsolinesRoutingConfig(redis_conn, plpy, username, orgname)
|
|
|
|
GD[cache_key] = isolines_routing_config
|
|
|
|
return True
|
2020-02-24 23:12:27 +08:00
|
|
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED;
|
2016-03-08 19:24:27 +08:00
|
|
|
|
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_routing_config(username text, orgname text)
|
|
|
|
RETURNS boolean AS $$
|
|
|
|
cache_key = "user_routing_config_{0}".format(username)
|
|
|
|
if cache_key in GD:
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
from cartodb_services.metrics import RoutingConfig
|
|
|
|
plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username))
|
|
|
|
redis_conn = GD["redis_connection_{0}".format(username)]['redis_metadata_connection']
|
|
|
|
routing_config = RoutingConfig(redis_conn, plpy, username, orgname)
|
|
|
|
GD[cache_key] = routing_config
|
|
|
|
return True
|
2020-02-24 23:12:27 +08:00
|
|
|
$$ LANGUAGE @@plpythonu@@ SECURITY DEFINER;
|