diff --git a/client/renderer/sql-template-renderer b/client/renderer/sql-template-renderer index a25969a..23bd1d1 100755 --- a/client/renderer/sql-template-renderer +++ b/client/renderer/sql-template-renderer @@ -61,9 +61,6 @@ class SqlTemplateRenderer if with_user_org parameters << { 'name' => 'username', 'type' => 'text' } parameters << { 'name' => 'orgname', 'type' => 'text' } - if requires_permission - parameters << { 'name' => 'appname', 'type' => 'text' } - end end parameters + @function_signature['params'].reject(&:empty?) end diff --git a/client/renderer/templates/20_public_functions.erb b/client/renderer/templates/20_public_functions.erb index 2b98906..3950037 100644 --- a/client/renderer/templates/20_public_functions.erb +++ b/client/renderer/templates/20_public_functions.erb @@ -9,17 +9,16 @@ RETURNS <%= return_type %> AS $$ DECLARE <%= return_declaration if not multi_row %> <%= user_org_declaration %> - <% unless superuser_function? -%>appname text; - apikey_permissions json;<% end %> + <% unless superuser_function? -%>apikey_permissions json;<% end %> BEGIN IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN RAISE EXCEPTION 'The api_key must be provided'; END IF; - <% unless superuser_function? -%>SELECT u, o, a, p INTO username, orgname, appname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, a text, p json); + <% unless superuser_function? -%>SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json); <% if requires_permission %>IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN RAISE EXCEPTION '<%= permission_error %>'; END IF; - <% else %>SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text, a text, p json);<% end %><% end %> + <% else %>SELECT u, o INTO username, orgname FROM <%= DATASERVICES_CLIENT_SCHEMA %>._cdb_entity_config() AS (u text, o text, p json);<% end %><% end %> -- JSON value stored "" is taken as literal IF username IS NULL OR username = '' OR username = '""' THEN RAISE EXCEPTION 'Username is a mandatory argument, check it out'; diff --git a/client/renderer/templates/25_exception_safe_private_functions.erb b/client/renderer/templates/25_exception_safe_private_functions.erb index 8d92420..0c5cdb2 100644 --- a/client/renderer/templates/25_exception_safe_private_functions.erb +++ b/client/renderer/templates/25_exception_safe_private_functions.erb @@ -10,13 +10,12 @@ DECLARE _returned_sqlstate TEXT; _message_text TEXT; _pg_exception_context TEXT; - <% unless superuser_function? -%>appname text; - apikey_permissions json;<% end %> + <% unless superuser_function? -%>apikey_permissions json;<% end %> BEGIN IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN RAISE EXCEPTION 'The api_key must be provided'; END IF; - <% unless superuser_function? -%>SELECT u, o, a, p INTO username, orgname, appname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, a text, p json); + <% unless superuser_function? -%>SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json); <% if requires_permission %>IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? '<%= permission_name %>' THEN RAISE EXCEPTION '<%= permission_error %>'; END IF; diff --git a/client/sql/15_config_management.sql b/client/sql/15_config_management.sql index 8eba064..d1e92f5 100644 --- a/client/sql/15_config_management.sql +++ b/client/sql/15_config_management.sql @@ -1,7 +1,6 @@ CREATE TYPE cdb_dataservices_client._entity_config AS ( username text, organization_name text, - application_name text, apikey_permissions json ); @@ -37,7 +36,6 @@ BEGIN END IF; result.username = username; result.organization_name = organization_name; - result.application_name = apikey_config->'application'; result.apikey_permissions = apikey_config->'permissions'; RETURN result; END; diff --git a/client/sql/21_bulk_geocoding_functions.sql b/client/sql/21_bulk_geocoding_functions.sql index edaefba..5fd9284 100644 --- a/client/sql/21_bulk_geocoding_functions.sql +++ b/client/sql/21_bulk_geocoding_functions.sql @@ -15,13 +15,12 @@ DECLARE temp_table_name text; username text; orgname text; - appname text; apikey_permissions json; BEGIN IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN RAISE EXCEPTION 'The api_key must be provided'; END IF; - SELECT u, o, a, p INTO username, orgname, appname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, a text, p json); + SELECT u, o, p INTO username, orgname, apikey_permissions FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text, p json); IF apikey_permissions IS NULL OR NOT apikey_permissions::jsonb ? 'geocoding' THEN RAISE EXCEPTION 'Geocoding is not allowed'; END IF; diff --git a/client/test/expected/10_admin0_test.out b/client/test/expected/10_admin0_test.out index 0da1802..190fef3 100644 --- a/client/test/expected/10_admin0_test.out +++ b/client/test/expected/10_admin0_test.out @@ -2,10 +2,10 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server function -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, appname text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (%, %, %, %)', username, orgname, appname, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (%, %, %)', username, orgname, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/expected/20_admin1_test.out b/client/test/expected/20_admin1_test.out index 63ee13d..590fb8f 100644 --- a/client/test/expected/20_admin1_test.out +++ b/client/test/expected/20_admin1_test.out @@ -2,17 +2,17 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, appname text, admin1_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', username, orgname, appname, admin1_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %)', username, orgname, admin1_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, appname text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %, %)', username, orgname, appname, admin1_name, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', username, orgname, admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/expected/25_exception_safe_private_functions_test.out b/client/test/expected/25_exception_safe_private_functions_test.out index 778b1d0..65d9df7 100644 --- a/client/test/expected/25_exception_safe_private_functions_test.out +++ b/client/test/expected/25_exception_safe_private_functions_test.out @@ -2,20 +2,20 @@ SET client_min_messages TO warning; SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions to raise exceptions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, appname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) RETURNS Geometry AS $$ BEGIN RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.'; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username text, orgname text, appname text, source geometry, mode text, range integer[], options text[] DEFAULT ARRAY[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username text, orgname text, source geometry, mode text, range integer[], options text[] DEFAULT ARRAY[]::text[]) RETURNS SETOF isoline AS $$ BEGIN RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.'; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, appname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') RETURNS cdb_dataservices_client.simple_route AS $$ DECLARE ret cdb_dataservices_client.simple_route; diff --git a/client/test/expected/30_namedplaces_test.out b/client/test/expected/30_namedplaces_test.out index d8515b3..1936f54 100644 --- a/client/test/expected/30_namedplaces_test.out +++ b/client/test/expected/30_namedplaces_test.out @@ -2,24 +2,24 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname text, city_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', username, orgname, appname, city_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %)', username, orgname, city_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname text, city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', username, orgname, appname, city_name, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', username, orgname, city_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname text, city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %, %)', username, orgname, appname, city_name, admin1_name, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', username, orgname, city_name, admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/expected/40_postalcodes_test.out b/client/test/expected/40_postalcodes_test.out index 6ed22f7..5af322f 100644 --- a/client/test/expected/40_postalcodes_test.out +++ b/client/test/expected/40_postalcodes_test.out @@ -2,17 +2,17 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, appname text, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %, %)', username, orgname, appname, postal_code, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %)', username, orgname, postal_code, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, appname text, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %, %)', username, orgname, appname, postal_code, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %)', username, orgname, postal_code, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/expected/50_ipaddresses_test.out b/client/test/expected/50_ipaddresses_test.out index 54bdbb1..fac1696 100644 --- a/client/test/expected/50_ipaddresses_test.out +++ b/client/test/expected/50_ipaddresses_test.out @@ -2,10 +2,10 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, appname text, ip_address text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, ip_address text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (%, %, %, %)', username, orgname, appname, ip_address; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (%, %, %)', username, orgname, ip_address; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/expected/60_street_test.out b/client/test/expected/60_street_test.out index adf14d4..2289058 100644 --- a/client/test/expected/60_street_test.out +++ b/client/test/expected/60_street_test.out @@ -2,10 +2,10 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, appname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (%, %, %, %, %, %, %)', username, orgname, appname, searchtext, city, state_province, country; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (%, %, %, %, %, %)', username, orgname, searchtext, city, state_province, country; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/expected/80_route_point_to_point_test.out b/client/test/expected/80_route_point_to_point_test.out index ef2a2a6..2984bbf 100644 --- a/client/test/expected/80_route_point_to_point_test.out +++ b/client/test/expected/80_route_point_to_point_test.out @@ -2,22 +2,22 @@ -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, appname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') RETURNS cdb_dataservices_client.simple_route AS $$ DECLARE ret cdb_dataservices_client.simple_route; BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_route_point_to_point invoked with params (%, %, %, %, %, %, %, %)', username, orgname, appname, origin, destination, mode, options, units; + RAISE NOTICE 'cdb_dataservices_server.cdb_route_point_to_point invoked with params (%, %, %, %, %, %, %)', username, orgname, origin, destination, mode, options, units; SELECT NULL, 5.33, 100 INTO ret; RETURN ret; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints(username text, orgname text, appname text, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints(username text, orgname text, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') RETURNS cdb_dataservices_client.simple_route AS $$ DECLARE ret cdb_dataservices_client.simple_route; BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_route_with_waypoints invoked with params (%, %, %, %, %, %, %)', username, orgname, appname, waypoints, mode, options, units; + RAISE NOTICE 'cdb_dataservices_server.cdb_route_with_waypoints invoked with params (%, %, %, %, %, %)', username, orgname, waypoints, mode, options, units; SELECT NULL, 2.22, 500 INTO ret; RETURN ret; END; diff --git a/client/test/expected/999_permissions_test.out b/client/test/expected/999_permissions_test.out index 2740658..c359e60 100644 --- a/client/test/expected/999_permissions_test.out +++ b/client/test/expected/999_permissions_test.out @@ -4,27 +4,27 @@ SET ROLE test_regular_user; -- Add to the search path the schema SET search_path TO public,cartodb,cdb_dataservices_client; -- Check the regular user has no permissions on private functions -SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'evil_appname', 'Hell'); +SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'Hell'); ERROR: permission denied for function _cdb_geocode_admin0_polygon -SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'evil_appname', 'Hell'); +SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Hell'); ERROR: permission denied for function _cdb_geocode_admin1_polygon -SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'evil_appname', 'Sheol', 'Hell'); +SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Sheol', 'Hell'); ERROR: permission denied for function _cdb_geocode_admin1_polygon -SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'evil_appname', 'Sheol'); +SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol'); ERROR: permission denied for function _cdb_geocode_namedplace_point -SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'evil_appname', 'Sheol', 'Hell'); +SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell'); ERROR: permission denied for function _cdb_geocode_namedplace_point -SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'evil_appname', 'Sheol', 'Hell', 'Ugly world'); +SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell', 'Ugly world'); ERROR: permission denied for function _cdb_geocode_namedplace_point -SELECT _cdb_geocode_postalcode_polygon('evil_user', 'evil_orgname', 'evil_appname', '66666', 'Hell'); +SELECT _cdb_geocode_postalcode_polygon('evil_user', 'evil_orgname', '66666', 'Hell'); ERROR: permission denied for function _cdb_geocode_postalcode_polygon -SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', 'evil_appname', '66666', 'Hell'); +SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', '66666', 'Hell'); ERROR: permission denied for function _cdb_geocode_postalcode_point -SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', 'evil_appname', '8.8.8.8'); +SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8'); ERROR: permission denied for function _cdb_geocode_ipaddress_point -SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'evil_appname', 'one street, 1'); +SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'one street, 1'); ERROR: permission denied for function _cdb_geocode_street_point -SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'evil_appname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car'); +SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car'); ERROR: permission denied for function _cdb_route_point_to_point -- -- Exercise the public function -- -- it is public, it shall work diff --git a/client/test/sql/10_admin0_test.sql b/client/test/sql/10_admin0_test.sql index f4d24c6..f5e1bd0 100644 --- a/client/test/sql/10_admin0_test.sql +++ b/client/test/sql/10_admin0_test.sql @@ -3,10 +3,10 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server function -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, appname text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (%, %, %, %)', username, orgname, appname, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin0_polygon invoked with params (%, %, %)', username, orgname, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/sql/20_admin1_test.sql b/client/test/sql/20_admin1_test.sql index ebefcb9..fd2250d 100644 --- a/client/test/sql/20_admin1_test.sql +++ b/client/test/sql/20_admin1_test.sql @@ -3,18 +3,18 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, appname text, admin1_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', username, orgname, appname, admin1_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %)', username, orgname, admin1_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, appname text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %, %)', username, orgname, appname, admin1_name, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_admin1_polygon invoked with params (%, %, %, %)', username, orgname, admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/sql/25_exception_safe_private_functions_test.sql b/client/test/sql/25_exception_safe_private_functions_test.sql index aeff422..45dbfca 100644 --- a/client/test/sql/25_exception_safe_private_functions_test.sql +++ b/client/test/sql/25_exception_safe_private_functions_test.sql @@ -3,7 +3,7 @@ SET client_min_messages TO warning; SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions to raise exceptions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, appname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) RETURNS Geometry AS $$ BEGIN RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.'; @@ -11,14 +11,14 @@ BEGIN END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username text, orgname text, appname text, source geometry, mode text, range integer[], options text[] DEFAULT ARRAY[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username text, orgname text, source geometry, mode text, range integer[], options text[] DEFAULT ARRAY[]::text[]) RETURNS SETOF isoline AS $$ BEGIN RAISE EXCEPTION 'Not enough quota or any other exception whatsoever.'; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, appname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') RETURNS cdb_dataservices_client.simple_route AS $$ DECLARE ret cdb_dataservices_client.simple_route; diff --git a/client/test/sql/30_namedplaces_test.sql b/client/test/sql/30_namedplaces_test.sql index 1d1d83c..e410a9c 100644 --- a/client/test/sql/30_namedplaces_test.sql +++ b/client/test/sql/30_namedplaces_test.sql @@ -3,26 +3,26 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname text, city_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', username, orgname, appname, city_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %)', username, orgname, city_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname text, city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', username, orgname, appname, city_name, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %)', username, orgname, city_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname text, city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %, %)', username, orgname, appname, city_name, admin1_name, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_namedplace_point invoked with params (%, %, %, %, %)', username, orgname, city_name, admin1_name, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/sql/40_postalcodes_test.sql b/client/test/sql/40_postalcodes_test.sql index 369a44b..ffb2d1b 100644 --- a/client/test/sql/40_postalcodes_test.sql +++ b/client/test/sql/40_postalcodes_test.sql @@ -3,18 +3,18 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, appname text, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %, %)', username, orgname, appname, postal_code, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_polygon invoked with params (%, %, %, %)', username, orgname, postal_code, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, appname text, postal_code text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, postal_code text, country_name text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %, %)', username, orgname, appname, postal_code, country_name; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_postalcode_point invoked with params (%, %, %, %)', username, orgname, postal_code, country_name; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/sql/50_ipaddresses_test.sql b/client/test/sql/50_ipaddresses_test.sql index 0c68dd2..901e21b 100644 --- a/client/test/sql/50_ipaddresses_test.sql +++ b/client/test/sql/50_ipaddresses_test.sql @@ -3,10 +3,10 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, appname text, ip_address text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, ip_address text) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (%, %, %, %)', username, orgname, appname, ip_address; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_ipaddress_point invoked with params (%, %, %)', username, orgname, ip_address; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/sql/60_street_test.sql b/client/test/sql/60_street_test.sql index ac0d107..17a7a61 100644 --- a/client/test/sql/60_street_test.sql +++ b/client/test/sql/60_street_test.sql @@ -3,10 +3,10 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, appname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL) RETURNS Geometry AS $$ BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (%, %, %, %, %, %, %)', username, orgname, appname, searchtext, city, state_province, country; + RAISE NOTICE 'cdb_dataservices_server.cdb_geocode_geocoder_street_point invoked with params (%, %, %, %, %, %)', username, orgname, searchtext, city, state_province, country; RETURN NULL; END; $$ LANGUAGE 'plpgsql'; diff --git a/client/test/sql/80_route_point_to_point_test.sql b/client/test/sql/80_route_point_to_point_test.sql index a995425..fcc04aa 100644 --- a/client/test/sql/80_route_point_to_point_test.sql +++ b/client/test/sql/80_route_point_to_point_test.sql @@ -4,24 +4,24 @@ SET search_path TO public,cartodb,cdb_dataservices_client; -- Mock the server functions -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, appname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point (username text, orgname text, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') RETURNS cdb_dataservices_client.simple_route AS $$ DECLARE ret cdb_dataservices_client.simple_route; BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_route_point_to_point invoked with params (%, %, %, %, %, %, %, %)', username, orgname, appname, origin, destination, mode, options, units; + RAISE NOTICE 'cdb_dataservices_server.cdb_route_point_to_point invoked with params (%, %, %, %, %, %, %)', username, orgname, origin, destination, mode, options, units; SELECT NULL, 5.33, 100 INTO ret; RETURN ret; END; $$ LANGUAGE 'plpgsql'; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints(username text, orgname text, appname text, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints(username text, orgname text, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], units text DEFAULT 'kilometers') RETURNS cdb_dataservices_client.simple_route AS $$ DECLARE ret cdb_dataservices_client.simple_route; BEGIN - RAISE NOTICE 'cdb_dataservices_server.cdb_route_with_waypoints invoked with params (%, %, %, %, %, %, %)', username, orgname, appname, waypoints, mode, options, units; + RAISE NOTICE 'cdb_dataservices_server.cdb_route_with_waypoints invoked with params (%, %, %, %, %, %)', username, orgname, waypoints, mode, options, units; SELECT NULL, 2.22, 500 INTO ret; RETURN ret; END; diff --git a/client/test/sql/999_permissions_test.sql b/client/test/sql/999_permissions_test.sql index 0417656..3adb266 100644 --- a/client/test/sql/999_permissions_test.sql +++ b/client/test/sql/999_permissions_test.sql @@ -6,17 +6,17 @@ SET ROLE test_regular_user; SET search_path TO public,cartodb,cdb_dataservices_client; -- Check the regular user has no permissions on private functions -SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'evil_appname', 'Hell'); -SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'evil_appname', 'Hell'); -SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'evil_appname', 'Sheol', 'Hell'); -SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'evil_appname', 'Sheol'); -SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'evil_appname', 'Sheol', 'Hell'); -SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'evil_appname', 'Sheol', 'Hell', 'Ugly world'); -SELECT _cdb_geocode_postalcode_polygon('evil_user', 'evil_orgname', 'evil_appname', '66666', 'Hell'); -SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', 'evil_appname', '66666', 'Hell'); -SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', 'evil_appname', '8.8.8.8'); -SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'evil_appname', 'one street, 1'); -SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'evil_appname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car'); +SELECT _cdb_geocode_admin0_polygon('evil_user', 'evil_orgname', 'Hell'); +SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Hell'); +SELECT _cdb_geocode_admin1_polygon('evil_user', 'evil_orgname', 'Sheol', 'Hell'); +SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol'); +SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell'); +SELECT _cdb_geocode_namedplace_point('evil_user', 'evil_orgname', 'Sheol', 'Hell', 'Ugly world'); +SELECT _cdb_geocode_postalcode_polygon('evil_user', 'evil_orgname', '66666', 'Hell'); +SELECT _cdb_geocode_postalcode_point('evil_user', 'evil_orgname', '66666', 'Hell'); +SELECT _cdb_geocode_ipaddress_point('evil_user', 'evil_orgname', '8.8.8.8'); +SELECT _cdb_geocode_street_point('evil_user', 'evil_orgname', 'one street, 1'); +SELECT _cdb_route_point_to_point('evil_user', 'evil_orgname', 'POINT(-87.81406 41.89308)'::geometry,'POINT(-87.79209 41.86138)'::geometry, 'car'); -- -- Exercise the public function -- -- it is public, it shall work diff --git a/server/extension/sql/105_route_between_points.sql b/server/extension/sql/105_route_between_points.sql index e6cede3..703e0dd 100644 --- a/server/extension/sql/105_route_between_points.sql +++ b/server/extension/sql/105_route_between_points.sql @@ -1,7 +1,6 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_point_to_point( username TEXT, orgname TEXT, - appname TEXT, origin geometry(Point, 4326), destination geometry(Point, 4326), mode TEXT, @@ -19,7 +18,7 @@ RETURNS cdb_dataservices_server.simple_route AS $$ logger_config = GD["logger_config"] logger = Logger(logger_config) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'origin': origin, 'destination': destination, 'mode': mode, 'options': options, 'units': units} + params = {'username': username, 'orgname': orgname, 'origin': origin, 'destination': destination, 'mode': mode, 'options': options, 'units': units} with metrics('cdb_route_with_point', user_routing_config, logger, params): waypoints = [origin, destination] @@ -44,7 +43,6 @@ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_route_with_waypoints( username TEXT, orgname TEXT, - appname TEXT, waypoints geometry(Point, 4326)[], mode TEXT, options text[] DEFAULT ARRAY[]::text[], @@ -61,7 +59,7 @@ RETURNS cdb_dataservices_server.simple_route AS $$ logger_config = GD["logger_config"] logger = Logger(logger_config) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'waypoints': waypoints, 'mode': mode, 'options': options, 'units': units} + params = {'username': username, 'orgname': orgname, 'waypoints': waypoints, 'mode': mode, 'options': options, 'units': units} with metrics('cdb_route_with_waypoints', user_routing_config, logger, params): if user_routing_config.mapzen_provider: diff --git a/server/extension/sql/20_geocode_street.sql b/server/extension/sql/20_geocode_street.sql index 30155a1..882d5e8 100644 --- a/server/extension/sql/20_geocode_street.sql +++ b/server/extension/sql/20_geocode_street.sql @@ -1,6 +1,6 @@ -- Geocodes a street address given a searchtext and a state and/or country -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_street_point(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.tools import Logger,LoggerConfig @@ -12,7 +12,7 @@ RETURNS Geometry AS $$ logger_config = GD["logger_config"] logger = Logger(logger_config) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'searchtext': searchtext, 'city': city, 'state_province': state_province, 'country': country} + params = {'username': username, 'orgname': orgname, 'searchtext': searchtext, 'city': city, 'state_province': state_province, 'country': country} with metrics('cdb_geocode_street_point', user_geocoder_config, logger, params): if user_geocoder_config.heremaps_geocoder: @@ -36,7 +36,7 @@ RETURNS Geometry AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_here_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_here_geocode_street_point(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -51,7 +51,7 @@ RETURNS Geometry AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_google_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_google_geocode_street_point(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -66,7 +66,7 @@ RETURNS Geometry AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapzen_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapzen_geocode_street_point(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ # The configuration is retrieved but no checks are performed on it plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) @@ -79,7 +79,7 @@ RETURNS Geometry AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapbox_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapbox_geocode_street_point(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ # The configuration is retrieved but no checks are performed on it plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) @@ -92,7 +92,7 @@ RETURNS Geometry AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_tomtom_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_tomtom_geocode_street_point(username TEXT, orgname TEXT, searchtext TEXT, city TEXT DEFAULT NULL, state_province TEXT DEFAULT NULL, country TEXT DEFAULT NULL) RETURNS Geometry AS $$ # The configuration is retrieved but no checks are performed on it plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) diff --git a/server/extension/sql/21_bulk_geocode_street.sql b/server/extension/sql/21_bulk_geocode_street.sql index 934abe3..173e684 100644 --- a/server/extension/sql/21_bulk_geocode_street.sql +++ b/server/extension/sql/21_bulk_geocode_street.sql @@ -5,7 +5,7 @@ CREATE TYPE cdb_dataservices_server.geocoding AS ( metadata jsonb ); -CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_bulk_geocode_street_point(username TEXT, orgname TEXT, appname TEXT, searches jsonb) +CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_bulk_geocode_street_point(username TEXT, orgname TEXT, searches jsonb) RETURNS SETOF cdb_dataservices_server.geocoding AS $$ from cartodb_services.metrics import metrics from cartodb_services.tools import Logger @@ -20,7 +20,7 @@ RETURNS SETOF cdb_dataservices_server.geocoding AS $$ logger_config = GD["logger_config"] logger = Logger(logger_config) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'searches': searches} + params = {'username': username, 'orgname': orgname, 'searches': searches} with metrics('cdb_bulk_geocode_street_point', user_geocoder_config, logger, params): if user_geocoder_config.google_geocoder: diff --git a/server/extension/sql/30_admin0.sql b/server/extension/sql/30_admin0.sql index 6e670ab..c5d8c8e 100644 --- a/server/extension/sql/30_admin0.sql +++ b/server/extension/sql/30_admin0.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, appname TEXT, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin0_polygon(username text, orgname text, country_name text) RETURNS Geometry AS $$ from cartodb_services.metrics import QuotaService from cartodb_services.metrics import InternalGeocoderConfig @@ -15,7 +15,7 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) quota_service = QuotaService(user_geocoder_config, redis_conn) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'country_name': country_name} + params = {'username': username, 'orgname': orgname, 'country_name': country_name} with metrics('cdb_geocode_admin0_polygon', user_geocoder_config, logger, params): try: diff --git a/server/extension/sql/40_admin1.sql b/server/extension/sql/40_admin1.sql index 99e28b4..c10e3b2 100644 --- a/server/extension/sql/40_admin1.sql +++ b/server/extension/sql/40_admin1.sql @@ -1,5 +1,5 @@ ---- cdb_geocode_admin1_polygon(admin1_name text) -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, appname TEXT, admin1_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService @@ -16,7 +16,7 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) quota_service = QuotaService(user_geocoder_config, redis_conn) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'admin1_name': admin1_name} + params = {'username': username, 'orgname': orgname, 'admin1_name': admin1_name} with metrics('cdb_geocode_admin1_polygon', user_geocoder_config, logger, params): try: @@ -39,7 +39,7 @@ RETURNS Geometry AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; ---- cdb_geocode_admin1_polygon(admin1_name text, country_name text) -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, appname TEXT, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_admin1_polygon(username text, orgname text, admin1_name text, country_name text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService diff --git a/server/extension/sql/50_namedplaces.sql b/server/extension/sql/50_namedplaces.sql index 07a18f0..932fc78 100644 --- a/server/extension/sql/50_namedplaces.sql +++ b/server/extension/sql/50_namedplaces.sql @@ -1,5 +1,5 @@ ---- cdb_geocode_namedplace_point(city_name text) -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname TEXT, city_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text) RETURNS Geometry AS $$ import spiexceptions from cartodb_services.tools import Logger,LoggerConfig @@ -9,17 +9,17 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) try: - street_point = plpy.prepare("SELECT cdb_dataservices_server.cdb_geocode_street_point($1, $2, $3, $4) as point;", ["text", "text", "text", "text"]) - return plpy.execute(street_point, [username, orgname, appname, city_name])[0]['point'] + street_point = plpy.prepare("SELECT cdb_dataservices_server.cdb_geocode_street_point($1, $2, $3) as point;", ["text", "text", "text"]) + return plpy.execute(street_point, [username, orgname, city_name])[0]['point'] except spiexceptions.ExternalRoutineException as e: import sys logger.error('Error geocoding namedplace using geocode street point, falling back to internal geocoder', sys.exc_info(), data={"username": username, "orgname": orgname}) - internal_plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_internal_geocode_namedplace($1, $2, $3, $4) as point;", ["text", "text", "text", "text"]) - return plpy.execute(internal_plan, [username, orgname, appname, city_name])[0]['point'] + internal_plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_internal_geocode_namedplace($1, $2, $3) as point;", ["text", "text", "text"]) + return plpy.execute(internal_plan, [username, orgname, city_name])[0]['point'] $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; ---- cdb_geocode_namedplace_point(city_name text, country_name text) -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname TEXT, city_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, country_name text) RETURNS Geometry AS $$ import spiexceptions from cartodb_services.tools import Logger,LoggerConfig @@ -29,17 +29,17 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) try: - street_point = plpy.prepare("SELECT cdb_dataservices_server.cdb_geocode_street_point($1, $2, $3, $4, NULL, NULL, $5) as point;", ["text", "text", "text", "text", "text"]) - return plpy.execute(street_point, [username, orgname, appname, city_name, country_name])[0]['point'] + street_point = plpy.prepare("SELECT cdb_dataservices_server.cdb_geocode_street_point($1, $2, $3, NULL, NULL, $4) as point;", ["text", "text", "text", "text"]) + return plpy.execute(street_point, [username, orgname, city_name, country_name])[0]['point'] except spiexceptions.ExternalRoutineException as e: import sys logger.error('Error geocoding namedplace using geocode street point, falling back to internal geocoder', sys.exc_info(), data={"username": username, "orgname": orgname}) - internal_plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_internal_geocode_namedplace($1, $2, $3, $4, NULL, $5) as point;", ["text", "text", "text", "text", "text"]) - return plpy.execute(internal_plan, [username, orgname, appname, city_name, country_name])[0]['point'] + internal_plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_internal_geocode_namedplace($1, $2, $3, NULL, $4) as point;", ["text", "text", "text", "text"]) + return plpy.execute(internal_plan, [username, orgname, city_name, country_name])[0]['point'] $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; ---- cdb_geocode_namedplace_point(city_name text, admin1_name text, country_name text) -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, appname TEXT, city_name text, admin1_name text, country_name text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_namedplace_point(username text, orgname text, city_name text, admin1_name text, country_name text) RETURNS Geometry AS $$ import spiexceptions from cartodb_services.tools import Logger,LoggerConfig @@ -49,16 +49,16 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) try: - street_point = plpy.prepare("SELECT cdb_dataservices_server.cdb_geocode_street_point($1, $2, $3, $4, NULL, $5, $6) as point;", ["text", "text", "text", "text", "text", "text"]) - return plpy.execute(street_point, [username, orgname, appname, city_name, admin1_name, country_name])[0]['point'] + street_point = plpy.prepare("SELECT cdb_dataservices_server.cdb_geocode_street_point($1, $2, $3, NULL, $4, $5) as point;", ["text", "text", "text", "text", "text"]) + return plpy.execute(street_point, [username, orgname, city_name, admin1_name, country_name])[0]['point'] except spiexceptions.ExternalRoutineException as e: import sys logger.error('Error geocoding namedplace using geocode street point, falling back to internal geocoder', sys.exc_info(), data={"username": username, "orgname": orgname}) - internal_plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_internal_geocode_namedplace($1, $2, $3, $4, $5, $6) as point;", ["text", "text", "text", "text", "text", "text"]) - return plpy.execute(internal_plan, [username, orgname, appname, city_name, admin1_name, country_name])[0]['point'] + internal_plan = plpy.prepare("SELECT cdb_dataservices_server._cdb_internal_geocode_namedplace($1, $2, $3, $4, $5) as point;", ["text", "text", "text", "text", "text"]) + return plpy.execute(internal_plan, [username, orgname, city_name, admin1_name, country_name])[0]['point'] $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_internal_geocode_namedplace(username text, orgname text, appname text, city_name text, admin1_name text DEFAULT NULL, country_name text DEFAULT NULL) +CREATE OR REPLACE FUNCTION cdb_dataservices_server._cdb_internal_geocode_namedplace(username text, orgname text, city_name text, admin1_name text DEFAULT NULL, country_name text DEFAULT NULL) RETURNS Geometry AS $$ from cartodb_services.metrics import QuotaService from cartodb_services.metrics import InternalGeocoderConfig, metrics @@ -74,7 +74,7 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) quota_service = QuotaService(user_geocoder_config, redis_conn) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'city_name': city_name, 'admin1_name': admin1_name, 'country_name': country_name} + params = {'username': username, 'orgname': orgname, 'city_name': city_name, 'admin1_name': admin1_name, 'country_name': country_name} with metrics('cdb_geocode_namedplace_point', user_geocoder_config, logger, params): try: diff --git a/server/extension/sql/60_postalcodes.sql b/server/extension/sql/60_postalcodes.sql index 8390e71..d82f42e 100644 --- a/server/extension/sql/60_postalcodes.sql +++ b/server/extension/sql/60_postalcodes.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, appname TEXT, code text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, code text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService @@ -15,7 +15,7 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) quota_service = QuotaService(user_geocoder_config, redis_conn) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'code': code} + params = {'username': username, 'orgname': orgname, 'code': code} with metrics('cdb_geocode_postalcode_point', user_geocoder_config, logger, params): try: @@ -37,13 +37,13 @@ RETURNS Geometry AS $$ quota_service.increment_total_service_use() $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, appname TEXT, code double precision) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, code double precision) RETURNS Geometry AS $$ - SELECT cdb_dataservices_server.cdb_geocode_postalcode_point(username, orgname, appname, code::text); + SELECT cdb_dataservices_server.cdb_geocode_postalcode_point(username, orgname, code::text); $$ LANGUAGE SQL STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, appname TEXT, code text, country text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, code text, country text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService @@ -79,13 +79,13 @@ RETURNS Geometry AS $$ quota_service.increment_total_service_use() $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, appname TEXT, code double precision, country text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_point(username text, orgname text, code double precision, country text) RETURNS Geometry AS $$ - SELECT cdb_dataservices_server.cdb_geocode_postalcode_point(username, orgname, appname, code::text, country); + SELECT cdb_dataservices_server.cdb_geocode_postalcode_point(username, orgname, code::text, country); $$ LANGUAGE SQL STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, appname TEXT, code text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, code text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService @@ -121,14 +121,14 @@ RETURNS Geometry AS $$ quota_service.increment_total_service_use() $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, appname TEXT, code double precision) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, code double precision) RETURNS Geometry AS $$ - SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon(username, orgname, appname, code::text) + SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon(username, orgname, code::text) $$ LANGUAGE SQL STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, appname TEXT, code text, country text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, code text, country text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService @@ -164,9 +164,9 @@ RETURNS Geometry AS $$ quota_service.increment_total_service_use() $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, appname TEXT, code double precision, country text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_postalcode_polygon(username text, orgname text, code double precision, country text) RETURNS Geometry AS $$ - SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon(username, orgname, appname, code::text, country); + SELECT cdb_dataservices_server.cdb_geocode_postalcode_polygon(username, orgname, code::text, country); $$ LANGUAGE SQL STABLE PARALLEL RESTRICTED; -------------------------------------------------------------------------------- diff --git a/server/extension/sql/70_ips.sql b/server/extension/sql/70_ips.sql index 7eb16e3..0f41c5a 100644 --- a/server/extension/sql/70_ips.sql +++ b/server/extension/sql/70_ips.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, appname TEXT, ip text) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_geocode_ipaddress_point(username text, orgname text, ip text) RETURNS Geometry AS $$ from cartodb_services.metrics import metrics from cartodb_services.metrics import QuotaService @@ -15,7 +15,7 @@ RETURNS Geometry AS $$ logger = Logger(logger_config) quota_service = QuotaService(user_geocoder_config, redis_conn) - params = {'username': username, 'orgname': orgname, 'appname': appname, 'ip': ip} + params = {'username': username, 'orgname': orgname, 'ip': ip} with metrics('cdb_geocode_ipaddress_point', user_geocoder_config, logger): try: diff --git a/server/extension/sql/85_isodistance.sql b/server/extension/sql/85_isodistance.sql index 3fb7feb..eadd0b8 100644 --- a/server/extension/sql/85_isodistance.sql +++ b/server/extension/sql/85_isodistance.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isodistance(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ from cartodb_services.metrics import metrics from cartodb_services.tools import Logger @@ -14,27 +14,27 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ if user_isolines_config.google_services_user: raise Exception('This service is not available for google service users.') - params = {'username': username, 'orgname': orgname, 'appname': appname, 'source': source, 'mode': mode, 'range': range, 'options': options} + params = {'username': username, 'orgname': orgname, 'source': source, 'mode': mode, 'range': range, 'options': options} with metrics('cdb_isodistance', user_isolines_config, logger, params): if user_isolines_config.heremaps_provider: here_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_here_isodistance($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(here_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(here_plan, [username, orgname, source, mode, range, options]) elif user_isolines_config.mapzen_provider: mapzen_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_mapzen_isodistance($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(mapzen_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(mapzen_plan, [username, orgname, source, mode, range, options]) elif user_isolines_config.mapbox_provider: mapbox_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_mapbox_isodistance($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(mapbox_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(mapbox_plan, [username, orgname, source, mode, range, options]) elif user_isolines_config.tomtom_provider: tomtom_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_tomtom_isodistance($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(tomtom_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(tomtom_plan, [username, orgname, source, mode, range, options]) else: raise Exception('Requested isolines provider is not available') $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- heremaps isodistance -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_here_isodistance(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_here_isodistance(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -49,7 +49,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- mapzen isodistance -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapzen_isodistance(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapzen_isodistance(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -63,7 +63,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- mapbox isodistance -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapbox_isodistance(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapbox_isodistance(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -77,7 +77,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- tomtom isodistance -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_tomtom_isodistance(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_tomtom_isodistance(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] diff --git a/server/extension/sql/90_isochrone.sql b/server/extension/sql/90_isochrone.sql index 5a06268..26d73d7 100644 --- a/server/extension/sql/90_isochrone.sql +++ b/server/extension/sql/90_isochrone.sql @@ -1,4 +1,4 @@ -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isochrone(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_isochrone(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ from cartodb_services.metrics import metrics from cartodb_services.tools import Logger @@ -14,27 +14,27 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ if user_isolines_config.google_services_user: raise Exception('This service is not available for google service users.') - params = {'username': username, 'orgname': orgname, 'appname': appname, 'source': source, 'mode': mode, 'range': range, 'options': options} + params = {'username': username, 'orgname': orgname, 'source': source, 'mode': mode, 'range': range, 'options': options} with metrics('cdb_isochrone', user_isolines_config, logger, params): if user_isolines_config.heremaps_provider: here_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_here_isochrone($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(here_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(here_plan, [username, orgname, source, mode, range, options]) elif user_isolines_config.mapzen_provider: mapzen_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_mapzen_isochrone($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(mapzen_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(mapzen_plan, [username, orgname, source, mode, range, options]) elif user_isolines_config.mapbox_provider: mapbox_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_mapbox_isochrone($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(mapbox_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(mapbox_plan, [username, orgname, source, mode, range, options]) elif user_isolines_config.tomtom_provider: tomtom_plan = plpy.prepare("SELECT * FROM cdb_dataservices_server.cdb_tomtom_isochrone($1, $2, $3, $4, $5, $6, $7) as isoline; ", ["text", "text", "geometry(geometry, 4326)", "text", "integer[]", "text[]"]) - return plpy.execute(tomtom_plan, [username, orgname, appname, source, mode, range, options]) + return plpy.execute(tomtom_plan, [username, orgname, source, mode, range, options]) else: raise Exception('Requested isolines provider is not available') $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- heremaps isochrone -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_here_isochrone(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_here_isochrone(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -49,7 +49,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- mapzen isochrone -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapzen_isochrone(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapzen_isochrone(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -62,7 +62,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- mapbox isochrone -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapbox_isochrone(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_mapbox_isochrone(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] @@ -75,7 +75,7 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ $$ LANGUAGE plpythonu STABLE PARALLEL RESTRICTED; -- tomtom isochrone -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_tomtom_isochrone(username TEXT, orgname TEXT, appname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_tomtom_isochrone(username TEXT, orgname TEXT, source geometry(Geometry, 4326), mode TEXT, range integer[], options text[] DEFAULT array[]::text[]) RETURNS SETOF cdb_dataservices_server.isoline AS $$ plpy.execute("SELECT cdb_dataservices_server._connect_to_redis('{0}')".format(username)) redis_conn = GD["redis_connection_{0}".format(username)]['redis_metrics_connection'] diff --git a/server/extension/test/expected/30_admin0_test.out b/server/extension/test/expected/30_admin0_test.out index 61fb151..bf164ad 100644 --- a/server/extension/test/expected/30_admin0_test.out +++ b/server/extension/test/expected/30_admin0_test.out @@ -1,6 +1,6 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'test_appname', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'Spain'); cdb_geocode_admin0_polygon ---------------------------- @@ -16,7 +16,7 @@ INSERT INTO ne_admin0_v3 (adm0_a3, the_geom) VALUES('ESP', ST_GeomFromText( -71.1031880899493 42.3152774590236))',4326) ); -- This should return the polygon inserted above -SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'test_appname', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'Spain'); cdb_geocode_admin0_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540 diff --git a/server/extension/test/expected/40_admin1_test.out b/server/extension/test/expected/40_admin1_test.out index 80a76ed..000ff55 100644 --- a/server/extension/test/expected/40_admin1_test.out +++ b/server/extension/test/expected/40_admin1_test.out @@ -1,12 +1,12 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California'); cdb_geocode_admin1_polygon ---------------------------- (1 row) -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California', 'United States'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California', 'United States'); cdb_geocode_admin1_polygon ---------------------------- @@ -22,13 +22,13 @@ INSERT INTO global_province_polygons (synonyms, iso3, the_geom) VALUES (Array['c -71.1031880899493 42.3152774590236))',4326) ); -- This should return the polygon inserted above -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California'); cdb_geocode_admin1_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540 (1 row) -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California', 'United States'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California', 'United States'); cdb_geocode_admin1_polygon -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 0103000020E61000000100000004000000D0EA37A29AC651C00FD603035B284540FEFCFB379AC651C0C0503E9F5B284540FFDDDD4D96C651C033AC3B284F284540D0EA37A29AC651C00FD603035B284540 diff --git a/server/extension/test/expected/50_namedplaces_test.out b/server/extension/test/expected/50_namedplaces_test.out index cab8f50..11fb98b 100644 --- a/server/extension/test/expected/50_namedplaces_test.out +++ b/server/extension/test/expected/50_namedplaces_test.out @@ -1,20 +1,20 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ------------------------------ (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Spain'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ------------------------------ (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Valencia', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Valencia', 'Spain'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ------------------------------ @@ -34,42 +34,42 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain', 'Spain'], 'E -- Insert dummy data into admin1 decoder table INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES'); -- This should return the point inserted above -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elche'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Spain'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elche', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche', 'Spain'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Valencia', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Valencia', 'Spain'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- 0101000020E6100000637FD93D7958E63F2ECA6C9049A24340 (1 row) -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elche', 'valencia', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche', 'valencia', 'Spain'); WARNING: Error geocoding namedplace using geocode street point, falling back to internal geocoder. Exception: spiexceptions.ExternalRoutineException: cartodb_services.metrics.config.ConfigException: There is no user config available. Please check your configuration.' cdb_geocode_namedplace_point ---------------------------------------------------- diff --git a/server/extension/test/expected/70_ips_test.out b/server/extension/test/expected/70_ips_test.out index f5ea404..39b5886 100644 --- a/server/extension/test/expected/70_ips_test.out +++ b/server/extension/test/expected/70_ips_test.out @@ -1,6 +1,6 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', 'test_appname', '0.0.0.0'); +SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', '0.0.0.0'); cdb_geocode_ipaddress_point ----------------------------- @@ -9,7 +9,7 @@ SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_or -- Insert dummy data into ip_address_locations INSERT INTO ip_address_locations VALUES ('::ffff:0.0.0.0'::inet, (ST_SetSRID(ST_MakePoint('40.40', '3.71'), 4326))); -- This should return the polygon inserted above -SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', 'test_appname', '0.0.0.0'); +SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', '0.0.0.0'); cdb_geocode_ipaddress_point ---------------------------------------------------- 0101000020E61000003333333333334440AE47E17A14AE0D40 diff --git a/server/extension/test/sql/30_admin0_test.sql b/server/extension/test/sql/30_admin0_test.sql index 7a558ea..ac8911b 100644 --- a/server/extension/test/sql/30_admin0_test.sql +++ b/server/extension/test/sql/30_admin0_test.sql @@ -1,6 +1,6 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'test_appname', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'Spain'); -- Insert some dummy synonym INSERT INTO admin0_synonyms (name, adm0_a3) VALUES ('Spain', 'ESP'); @@ -14,7 +14,7 @@ INSERT INTO ne_admin0_v3 (adm0_a3, the_geom) VALUES('ESP', ST_GeomFromText( ); -- This should return the polygon inserted above -SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'test_appname', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_admin0_polygon('test_user', 'test_orgname', 'Spain'); -- Check for admin0 signatures SELECT exists(SELECT * diff --git a/server/extension/test/sql/40_admin1_test.sql b/server/extension/test/sql/40_admin1_test.sql index d8c963a..547cade 100644 --- a/server/extension/test/sql/40_admin1_test.sql +++ b/server/extension/test/sql/40_admin1_test.sql @@ -1,7 +1,7 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California'); -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California', 'United States'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California', 'United States'); -- Insert dummy data into country decoder table INSERT INTO country_decoder (synonyms, iso3) VALUES (Array['united states'], 'USA'); @@ -15,8 +15,8 @@ INSERT INTO global_province_polygons (synonyms, iso3, the_geom) VALUES (Array['c ); -- This should return the polygon inserted above -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California'); -SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'test_appname', 'California', 'United States'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California'); +SELECT cdb_dataservices_server.cdb_geocode_admin1_polygon('test_user', 'test_orgname', 'California', 'United States'); -- Check for admin1 signatures SELECT exists(SELECT * diff --git a/server/extension/test/sql/50_namedplaces_test.sql b/server/extension/test/sql/50_namedplaces_test.sql index dd19a88..ca601b0 100644 --- a/server/extension/test/sql/50_namedplaces_test.sql +++ b/server/extension/test/sql/50_namedplaces_test.sql @@ -1,8 +1,8 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Spain'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Valencia', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Valencia', 'Spain'); -- Insert dummy data into points table INSERT INTO global_cities_points_limited (geoname_id, name, iso2, admin1, admin2, population, lowername, the_geom) VALUES (3128760, 'Elche', 'ES', 'Valencia', 'AL', 34534, 'elche', ST_GeomFromText( @@ -21,12 +21,12 @@ INSERT INTO country_decoder (synonyms, iso2) VALUES (Array['spain', 'Spain'], 'E INSERT INTO admin1_decoder (admin1, synonyms, iso2) VALUES ('Valencia', Array['valencia', 'Valencia'], 'ES'); -- This should return the point inserted above -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elche'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Spain'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elche', 'Spain'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elx', 'Valencia', 'Spain'); -SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'test_appname', 'Elche', 'valencia', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elx', 'Valencia', 'Spain'); +SELECT cdb_dataservices_server.cdb_geocode_namedplace_point('test_user', 'test_orgname', 'Elche', 'valencia', 'Spain'); -- Check for namedplaces signatures SELECT exists(SELECT * diff --git a/server/extension/test/sql/70_ips_test.sql b/server/extension/test/sql/70_ips_test.sql index 79bea61..ba69842 100644 --- a/server/extension/test/sql/70_ips_test.sql +++ b/server/extension/test/sql/70_ips_test.sql @@ -1,12 +1,12 @@ -- Check that the public function is callable, even with no data -- It should return NULL -SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', 'test_appname', '0.0.0.0'); +SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', '0.0.0.0'); -- Insert dummy data into ip_address_locations INSERT INTO ip_address_locations VALUES ('::ffff:0.0.0.0'::inet, (ST_SetSRID(ST_MakePoint('40.40', '3.71'), 4326))); -- This should return the polygon inserted above -SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', 'test_appname', '0.0.0.0'); +SELECT cdb_dataservices_server.cdb_geocode_ipaddress_point('test_user', 'test_orgname', '0.0.0.0'); -- Check for namedplaces signatures (point and polygon) SELECT exists(SELECT *