Refactor, extracted user_service

This commit is contained in:
Mario de Frutos
2015-11-10 16:32:53 +01:00
parent bb3b2cc2da
commit 7eab3e1f90
4 changed files with 86 additions and 77 deletions

View File

@@ -1,7 +1,7 @@
# cdb_conf geocoder config example
INSERT INTO cdb_conf VALUES ('geocoder_conf', '{"geocoder_db": {"host": "localhost", "port": "5432", db": "cartodb_dev_user_274bf952-8568-4598-9efd-be92ed3d2ead_db", "user": "development_cartodb_user_274bf952-8568-4598-9efd-be92ed3d2ead"}, "redis": {"host": "localhost", "port": 6379, "db": 5 } }')
CREATE OR REPLACE FUNCTION cartodb._Geocoder_Admin0_Polygons(search text)
CREATE OR REPLACE FUNCTION cartodb._geocoder_admin0_polygons(search text)
RETURNS Geometry AS
$$
db_connection_str = plpy.execute("SELECT * FROM cartodb._Geocoder_Server_Conf() conf;")[0]['conf']
@@ -9,7 +9,7 @@ $$
$$ LANGUAGE plpythonu SECURITY DEFINER;
CREATE OR REPLACE
FUNCTION cartodb._Geocoder_Server_Conf()
FUNCTION cartodb._geocoder_server_conf()
RETURNS text AS
$$
conf = plpy.execute("SELECT cartodb.CDB_Conf_GetConf('geocoder_conf') conf")[0]['conf']
@@ -22,7 +22,7 @@ $$
return "host={0} port={1} dbname={2} user={3}".format(db_params['host'],db_params['port'],db_params['db'],db_params['user'])
$$ LANGUAGE 'plpythonu';
CREATE OR REPLACE FUNCTION cartodb._Geocoder_Admin0_Polygons(search text, user_id name, tx_id bigint, db_connection_str text)
CREATE OR REPLACE FUNCTION cartodb._geocoder_admin0_polygons(search text, user_id name, tx_id bigint, db_connection_str text)
RETURNS Geometry AS $$
CONNECT db_connection_str;
SELECT geocode_admin0(search, tx_id, user_id);