Skip to content

Commit

Permalink
Merge pull request #621 from CartoDB/development
Browse files Browse the repository at this point in the history
Update master branch
  • Loading branch information
Jesus89 authored Mar 31, 2021
2 parents 695aafd + 07de813 commit aad5044
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
8 changes: 7 additions & 1 deletion client/cdb_dataservices_client--0.31.0--0.30.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 $$
Expand Down
19 changes: 7 additions & 12 deletions server/extension/cdb_dataservices_server--0.39.3--0.40.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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;
8 changes: 7 additions & 1 deletion server/extension/cdb_dataservices_server--0.40.0--0.39.3.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit aad5044

Please sign in to comment.