Rename service_params to service_quota_info #302
This commit is contained in:
parent
c2ede37d75
commit
769b740ba4
@ -377,8 +377,8 @@
|
|||||||
params:
|
params:
|
||||||
- { name: aggregate_type, type: text, default: 'NULL' }
|
- { name: aggregate_type, type: text, default: 'NULL' }
|
||||||
|
|
||||||
- name: cdb_service_params
|
- name: cdb_service_quota_info
|
||||||
return_type: SETOF cdb_dataservices_client.service_params
|
return_type: SETOF cdb_dataservices_client.service_quota_info
|
||||||
multi_row: true
|
multi_row: true
|
||||||
params:
|
params:
|
||||||
- {}
|
- {}
|
||||||
|
@ -28,7 +28,7 @@ CREATE TYPE cdb_dataservices_client.service_type AS ENUM (
|
|||||||
'observatory'
|
'observatory'
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TYPE cdb_dataservices_client.service_params AS (
|
CREATE TYPE cdb_dataservices_client.service_quota_info AS (
|
||||||
service cdb_dataservices_client.service_type,
|
service cdb_dataservices_client.service_type,
|
||||||
monthly_quota NUMERIC,
|
monthly_quota NUMERIC,
|
||||||
used_quota NUMERIC,
|
used_quota NUMERIC,
|
||||||
|
@ -12,8 +12,8 @@ END $$;
|
|||||||
|
|
||||||
DO $$
|
DO $$
|
||||||
BEGIN
|
BEGIN
|
||||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'service_params') THEN
|
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'service_quota_info') THEN
|
||||||
CREATE TYPE cdb_dataservices_server.service_params AS (
|
CREATE TYPE cdb_dataservices_server.service_quota_info AS (
|
||||||
service cdb_dataservices_server.service_type,
|
service cdb_dataservices_server.service_type,
|
||||||
monthly_quota NUMERIC,
|
monthly_quota NUMERIC,
|
||||||
used_quota NUMERIC,
|
used_quota NUMERIC,
|
||||||
@ -23,10 +23,10 @@ BEGIN
|
|||||||
END IF;
|
END IF;
|
||||||
END $$;
|
END $$;
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_service_params(
|
CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_service_quota_info(
|
||||||
username TEXT,
|
username TEXT,
|
||||||
orgname 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 cartodb_services.metrics.user import UserMetricsService
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
@ -95,10 +95,10 @@ CREATE OR REPLACE FUNCTION cdb_dataservices_server.cdb_enough_quota(
|
|||||||
input_size NUMERIC)
|
input_size NUMERIC)
|
||||||
returns BOOLEAN AS $$
|
returns BOOLEAN AS $$
|
||||||
DECLARE
|
DECLARE
|
||||||
params cdb_dataservices_server.service_params;
|
params cdb_dataservices_server.service_quota_info;
|
||||||
BEGIN
|
BEGIN
|
||||||
SELECT * INTO params
|
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_;
|
WHERE p.service = service_;
|
||||||
RETURN params.soft_limit OR ((params.used_quota + input_size) <= params.monthly_quota);
|
RETURN params.soft_limit OR ((params.used_quota + input_size) <= params.monthly_quota);
|
||||||
END
|
END
|
||||||
|
Loading…
Reference in New Issue
Block a user