From 6ebc5a389b363e1ebdff56407c0bf3ec6c3460ed Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 30 Sep 2021 10:17:25 +0100 Subject: [PATCH 1/2] remove cloud limits for certain tenants --- packages/server/src/middleware/usageQuota.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/server/src/middleware/usageQuota.js b/packages/server/src/middleware/usageQuota.js index 3a244ef5bc..de54c93200 100644 --- a/packages/server/src/middleware/usageQuota.js +++ b/packages/server/src/middleware/usageQuota.js @@ -1,6 +1,10 @@ const CouchDB = require("../db") const usageQuota = require("../utilities/usageQuota") const env = require("../environment") +const { getTenantId } = require("@budibase/auth/tenancy") + +// tenants without limits +const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"] // currently only counting new writes and deletes const METHOD_MAP = { @@ -28,8 +32,10 @@ function getProperty(url) { } module.exports = async (ctx, next) => { + const tenantId = getTenantId() + // if in development or a self hosted cloud usage quotas should not be executed - if (env.isDev() || env.SELF_HOSTED) { + if (env.isDev() || env.SELF_HOSTED || EXCLUDED_TENANTS.includes(tenantId)) { return next() } From 6681542ab548f15a5d319295f1169e14754810d7 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 30 Sep 2021 10:35:53 +0100 Subject: [PATCH 2/2] fix tests --- packages/server/src/middleware/tests/usageQuota.spec.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/server/src/middleware/tests/usageQuota.spec.js b/packages/server/src/middleware/tests/usageQuota.spec.js index d828f2ca60..7a64b1a039 100644 --- a/packages/server/src/middleware/tests/usageQuota.spec.js +++ b/packages/server/src/middleware/tests/usageQuota.spec.js @@ -6,6 +6,9 @@ jest.mock("../../environment", () => ({ isDev: () => true, _set: () => {}, })) +jest.mock("@budibase/auth/tenancy", () => ({ + getTenantId: () => "testing123" +})) const usageQuotaMiddleware = require("../usageQuota") const usageQuota = require("../../utilities/usageQuota")