diff --git a/client/cdb_dataservices_client--0.31.0--0.30.0.sql b/client/cdb_dataservices_client--0.31.0--0.30.0.sql index b2f52a6..9a006b7 100644 --- a/client/cdb_dataservices_client--0.31.0--0.30.0.sql +++ b/client/cdb_dataservices_client--0.31.0--0.30.0.sql @@ -12,7 +12,13 @@ CREATE TYPE cdb_dataservices_client.obs_meta_denominator AS (denom_id text, deno CREATE TYPE cdb_dataservices_client.obs_meta_geometry AS (geom_id text, geom_name text, geom_description text, geom_weight text, geom_aggregate text, geom_license text, geom_source text, valid_numer boolean, valid_denom boolean, valid_timespan boolean, score numeric, numtiles bigint, notnull_percent numeric, numgeoms numeric, percentfill numeric, estnumgeoms numeric, meanmediansize numeric, geom_type text, geom_extra jsonb, geom_tags jsonb); CREATE TYPE cdb_dataservices_client.obs_meta_timespan AS (timespan_id text, timespan_name text, timespan_description text, timespan_weight text, timespan_aggregate text, timespan_license text, timespan_source text, valid_numer boolean, valid_denom boolean, valid_geom boolean, timespan_type text, timespan_extra jsonb, timespan_tags jsonb); -ALTER TYPE cdb_dataservices_client.service_type ADD VALUE 'observatory' AFTER 'routing'; +WITH c AS ( + SELECT pg_type.oid as id + FROM pg_type INNER JOIN pg_namespace ON (pg_type.typnamespace = pg_namespace.oid) + WHERE pg_type.typname = 'service_type' AND pg_namespace.nspname = 'cdb_dataservices_client' +) +INSERT INTO pg_enum (enumtypid, enumsortorder, enumlabel) +SELECT c.id, 4, 'observatory' FROM c; CREATE OR REPLACE FUNCTION cdb_dataservices_client.obs_get_demographic_snapshot (geom public.geometry(Geometry, 4326) ,time_span text DEFAULT '2009 - 2013'::text ,geometry_level text DEFAULT NULL) RETURNS json AS $$ diff --git a/server/extension/cdb_dataservices_server--0.39.3--0.40.0.sql b/server/extension/cdb_dataservices_server--0.39.3--0.40.0.sql index 6880789..dc0a9c7 100644 --- a/server/extension/cdb_dataservices_server--0.39.3--0.40.0.sql +++ b/server/extension/cdb_dataservices_server--0.39.3--0.40.0.sql @@ -65,6 +65,13 @@ DROP FUNCTION IF EXISTS cdb_dataservices_server.OBS_LegacyBuilderMetadata(TEXT, DROP FUNCTION IF EXISTS cdb_dataservices_server._OBS_GetNumerators (TEXT, TEXT, geometry(Geometry, 4326), TEXT[], TEXT[] , TEXT[], TEXT[] , TEXT, TEXT, TEXT, TEXT); DROP FUNCTION IF EXISTS cdb_dataservices_server._get_obs_config(TEXT, TEXT); +DROP TYPE IF EXISTS cdb_dataservices_server.obs_meta_numerator; +DROP TYPE IF EXISTS cdb_dataservices_server.obs_meta_denominator; +DROP TYPE IF EXISTS cdb_dataservices_server.obs_meta_geometry; +DROP TYPE IF EXISTS cdb_dataservices_server.obs_meta_timespan; +DROP TYPE IF EXISTS cdb_dataservices_server.ds_fdw_metadata; +DROP TYPE IF EXISTS cdb_dataservices_server.ds_return_metadata; + DELETE FROM pg_enum WHERE enumlabel = 'observatory' AND enumtypid = ( @@ -122,17 +129,5 @@ RETURNS SETOF cdb_dataservices_server.service_quota_info AS $$ provider = user_routing_config.provider ret += [[service, monthly_quota, used_quota, soft_limit, provider]] - #-- Observatory - service = 'observatory' - plpy.execute("SELECT cdb_dataservices_server._get_obs_config({0}, {1})".format(plpy.quote_nullable(username), plpy.quote_nullable(orgname))) - user_obs_config = GD["user_obs_config_{0}".format(username)] - user_service = UserMetricsService(user_obs_config, redis_conn) - - monthly_quota = user_obs_config.monthly_quota - used_quota = user_service.used_quota(user_obs_config.service_type, today) - soft_limit = user_obs_config.soft_limit - provider = user_obs_config.provider - ret += [[service, monthly_quota, used_quota, soft_limit, provider]] - return ret $$ LANGUAGE @@plpythonu@@ STABLE PARALLEL RESTRICTED; diff --git a/server/extension/cdb_dataservices_server--0.40.0--0.39.3.sql b/server/extension/cdb_dataservices_server--0.40.0--0.39.3.sql index 29b8c87..65c94a2 100644 --- a/server/extension/cdb_dataservices_server--0.40.0--0.39.3.sql +++ b/server/extension/cdb_dataservices_server--0.40.0--0.39.3.sql @@ -1446,7 +1446,13 @@ RETURNS boolean AS $$ return True $$ LANGUAGE @@plpythonu@@ SECURITY DEFINER STABLE PARALLEL RESTRICTED; -ALTER TYPE cdb_dataservices_server.service_type ADD VALUE 'observatory' AFTER 'routing'; +WITH c AS ( + SELECT pg_type.oid as id + FROM pg_type INNER JOIN pg_namespace ON (pg_type.typnamespace = pg_namespace.oid) + WHERE pg_type.typname = 'service_type' AND pg_namespace.nspname = 'cdb_dataservices_server' +) +INSERT INTO pg_enum (enumtypid, enumsortorder, enumlabel) +SELECT c.id, 4, 'observatory' FROM c; CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_service_quota_info( username TEXT,