From 769b740ba40357d3eabaf65bf7b5fb7dd7a636e7 Mon Sep 17 00:00:00 2001 From: Rafa de la Torre Date: Thu, 24 Nov 2016 17:46:07 +0100 Subject: [PATCH] Rename service_params to service_quota_info #302 --- client/renderer/interface.yaml | 4 ++-- client/sql/16_custom_types.sql | 2 +- server/extension/sql/200_quotas.sql | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client/renderer/interface.yaml b/client/renderer/interface.yaml index a40c99d..8c33801 100644 --- a/client/renderer/interface.yaml +++ b/client/renderer/interface.yaml @@ -377,8 +377,8 @@ params: - { name: aggregate_type, type: text, default: 'NULL' } -- name: cdb_service_params - return_type: SETOF cdb_dataservices_client.service_params +- name: cdb_service_quota_info + return_type: SETOF cdb_dataservices_client.service_quota_info multi_row: true params: - {} diff --git a/client/sql/16_custom_types.sql b/client/sql/16_custom_types.sql index a316d8e..37e62f9 100644 --- a/client/sql/16_custom_types.sql +++ b/client/sql/16_custom_types.sql @@ -28,7 +28,7 @@ CREATE TYPE cdb_dataservices_client.service_type AS ENUM ( 'observatory' ); -CREATE TYPE cdb_dataservices_client.service_params AS ( +CREATE TYPE cdb_dataservices_client.service_quota_info AS ( service cdb_dataservices_client.service_type, monthly_quota NUMERIC, used_quota NUMERIC, diff --git a/server/extension/sql/200_quotas.sql b/server/extension/sql/200_quotas.sql index 34f5279..c0aefca 100644 --- a/server/extension/sql/200_quotas.sql +++ b/server/extension/sql/200_quotas.sql @@ -12,8 +12,8 @@ END $$; DO $$ BEGIN - IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'service_params') THEN - CREATE TYPE cdb_dataservices_server.service_params AS ( + IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'service_quota_info') THEN + CREATE TYPE cdb_dataservices_server.service_quota_info AS ( service cdb_dataservices_server.service_type, monthly_quota NUMERIC, used_quota NUMERIC, @@ -23,10 +23,10 @@ BEGIN END IF; END $$; -CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_service_params( +CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_service_quota_info( username TEXT, orgname TEXT) -RETURNS SETOF cdb_dataservices_server.service_params AS $$ +RETURNS SETOF cdb_dataservices_server.service_quota_info AS $$ from cartodb_services.metrics.user import UserMetricsService from datetime import date @@ -95,10 +95,10 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_enough_quota( input_size NUMERIC) returns BOOLEAN AS $$ DECLARE - params cdb_dataservices_server.service_params; + params cdb_dataservices_server.service_quota_info; BEGIN SELECT * INTO params - FROM cdb_dataservices_server.cdb_service_params(username, orgname) AS p + FROM cdb_dataservices_server.cdb_service_quota_info(username, orgname) AS p WHERE p.service = service_; RETURN params.soft_limit OR ((params.used_quota + input_size) <= params.monthly_quota); END