diff --git a/client/cdb_dataservices_client--0.10.0--0.9.0.sql b/client/cdb_dataservices_client--0.10.0--0.9.0.sql index 144e964..4fdb771 100644 --- a/client/cdb_dataservices_client--0.10.0--0.9.0.sql +++ b/client/cdb_dataservices_client--0.10.0--0.9.0.sql @@ -9,6 +9,8 @@ DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_ConnectUserTable(text, text DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_GetReturnMetadata(text, text, text, json); DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_FetchJoinFdwTableData(text, text, text, text, text, json); DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_DisconnectUserTable(text, text, text, text, text); +DROP FUNCTION IF EXISTS cdb_dataservices_client.OBS_DumpVersion(); +DROP FUNCTION IF EXISTS cdb_dataservices_client._OBS_DumpVersion(text, text); DROP TYPE IF EXISTS cdb_dataservices_client.ds_fdw_metadata; DROP TYPE IF EXISTS cdb_dataservices_client.ds_return_metadata; diff --git a/client/cdb_dataservices_client--0.9.0--0.10.0.sql b/client/cdb_dataservices_client--0.9.0--0.10.0.sql index b734241..35b03d8 100644 --- a/client/cdb_dataservices_client--0.9.0--0.10.0.sql +++ b/client/cdb_dataservices_client--0.9.0--0.10.0.sql @@ -266,5 +266,38 @@ RETURNS boolean AS $$ TARGET cdb_dataservices_server._OBS_DisconnectUserTable; $$ LANGUAGE plproxy; +CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_dumpversion () +RETURNS text AS $$ +DECLARE + ret text; + username text; + orgname text; +BEGIN + IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN + RAISE EXCEPTION 'The api_key must be provided'; + END IF; + SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text); + -- 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'; + END IF; + + SELECT * FROM cdb_dataservices_client._obs_dumpversion(username, orgname) INTO ret; + RETURN ret; + +END; +$$ LANGUAGE 'plpgsql' SECURITY DEFINER; + + +CREATE OR REPLACE FUNCTION cdb_dataservices_client._obs_dumpversion (username text, organization_name text) + +RETURNS text AS $$ + CONNECT cdb_dataservices_client._server_conn_str(); + + SELECT * FROM cdb_dataservices_server.obs_dumpversion (username, organization_name); + +$$ LANGUAGE plproxy; + GRANT EXECUTE ON FUNCTION cdb_dataservices_client._OBS_AugmentTable(text, text, json) TO publicuser; GRANT EXECUTE ON FUNCTION cdb_dataservices_client._OBS_GetTable(text, text, text, json) TO publicuser; +GRANT EXECUTE ON FUNCTION cdb_dataservices_client.OBS_DumpVersion() TO publicuser; diff --git a/server/extension/cdb_dataservices_server--0.12.0--0.13.0.sql b/server/extension/cdb_dataservices_server--0.12.0--0.13.0.sql index 9d22888..ba7cf27 100644 --- a/server/extension/cdb_dataservices_server--0.12.0--0.13.0.sql +++ b/server/extension/cdb_dataservices_server--0.12.0--0.13.0.sql @@ -140,4 +140,10 @@ RETURNS SETOF cdb_dataservices_server.isoline AS $$ result = plpy.execute(mapzen_plan, [username, orgname, type, source, mode, range, options]) return result -$$ LANGUAGE plpythonu; \ No newline at end of file +$$ LANGUAGE plpythonu; + +CREATE OR REPLACE FUNCTION cdb_dataservices_server.obs_dumpversion(username text, orgname text) +RETURNS text AS $$ + CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname); + SELECT cdb_observatory.obs_dumpversion(); +$$ LANGUAGE plproxy; diff --git a/server/extension/cdb_dataservices_server--0.13.0--0.12.0.sql b/server/extension/cdb_dataservices_server--0.13.0--0.12.0.sql index 932b03c..33bdc46 100644 --- a/server/extension/cdb_dataservices_server--0.13.0--0.12.0.sql +++ b/server/extension/cdb_dataservices_server--0.13.0--0.12.0.sql @@ -8,6 +8,7 @@ DROP FUNCTION IF EXISTS cdb_dataservices_server.__OBS_ConnectUserTable(text, tex DROP FUNCTION IF EXISTS cdb_dataservices_server._OBS_GetReturnMetadata(text, text, text, json); DROP FUNCTION IF EXISTS cdb_dataservices_server._OBS_FetchJoinFdwTableData(text, text, text, text, text, json); DROP FUNCTION IF EXISTS cdb_dataservices_server._OBS_DisconnectUserTable(text, text, text, text, text); +DROP FUNCTION IF EXISTS cdb_dataservices_server.OBS_DumpVersion(text, text); DROP TYPE IF EXISTS cdb_dataservices_server.ds_fdw_metadata; DROP TYPE IF EXISTS cdb_dataservices_server.ds_return_metadata; diff --git a/server/extension/cdb_dataservices_server--0.13.0.sql b/server/extension/cdb_dataservices_server--0.13.0.sql index 9e4111b..de79e50 100644 --- a/server/extension/cdb_dataservices_server--0.13.0.sql +++ b/server/extension/cdb_dataservices_server--0.13.0.sql @@ -1170,7 +1170,8 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_server.obs_dumpversion(username text RETURNS text AS $$ CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname); SELECT cdb_observatory.obs_dumpversion(); -$$ LANGUAGE plproxy;CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_geocoder_config(username text, orgname text) +$$ LANGUAGE plproxy; +CREATE OR REPLACE FUNCTION cdb_dataservices_server._get_geocoder_config(username text, orgname text) RETURNS boolean AS $$ cache_key = "user_geocoder_config_{0}".format(username) if cache_key in GD: diff --git a/server/extension/sql/130_data_observatory_helper.sql b/server/extension/sql/130_data_observatory_helper.sql new file mode 100644 index 0000000..841872c --- /dev/null +++ b/server/extension/sql/130_data_observatory_helper.sql @@ -0,0 +1,5 @@ +CREATE OR REPLACE FUNCTION cdb_dataservices_server.obs_dumpversion(username text, orgname text) +RETURNS text AS $$ + CONNECT cdb_dataservices_server._obs_server_conn_str(username, orgname); + SELECT cdb_observatory.obs_dumpversion(); +$$ LANGUAGE plproxy;