From af7c64255bdcf9fdabb2e52189dbb15ea74807b7 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Fri, 19 Aug 2022 09:28:26 +0100 Subject: [PATCH] usage page updates --- .../src/migrations/definitions.ts | 8 ------- .../bbui/src/ProgressBar/ProgressBar.svelte | 15 ++++++++++++- .../server/src/api/controllers/application.ts | 1 - .../src/api/controllers/deploy/index.ts | 7 +------ .../migrations/functions/backfill/global.ts | 3 --- .../migrations/functions/developerQuota.ts | 15 ------------- .../functions/publishedAppsQuota.ts | 13 ------------ .../functions/usageQuotas/syncDevelopers.ts | 19 ----------------- .../usageQuotas/syncPublishedApps.ts | 21 ------------------- packages/server/src/migrations/index.ts | 16 -------------- packages/types/src/sdk/migrations.ts | 2 -- packages/worker/src/sdk/users/users.ts | 12 +---------- 12 files changed, 16 insertions(+), 116 deletions(-) delete mode 100644 packages/server/src/migrations/functions/developerQuota.ts delete mode 100644 packages/server/src/migrations/functions/publishedAppsQuota.ts delete mode 100644 packages/server/src/migrations/functions/usageQuotas/syncDevelopers.ts delete mode 100644 packages/server/src/migrations/functions/usageQuotas/syncPublishedApps.ts diff --git a/packages/backend-core/src/migrations/definitions.ts b/packages/backend-core/src/migrations/definitions.ts index 745c8718c9..63df17b464 100644 --- a/packages/backend-core/src/migrations/definitions.ts +++ b/packages/backend-core/src/migrations/definitions.ts @@ -17,14 +17,6 @@ export const DEFINITIONS: MigrationDefinition[] = [ type: MigrationType.APP, name: MigrationName.APP_URLS, }, - { - type: MigrationType.GLOBAL, - name: MigrationName.DEVELOPER_QUOTA, - }, - { - type: MigrationType.GLOBAL, - name: MigrationName.PUBLISHED_APP_QUOTA, - }, { type: MigrationType.APP, name: MigrationName.EVENT_APP_BACKFILL, diff --git a/packages/bbui/src/ProgressBar/ProgressBar.svelte b/packages/bbui/src/ProgressBar/ProgressBar.svelte index 0bc50fb452..9219d068e1 100644 --- a/packages/bbui/src/ProgressBar/ProgressBar.svelte +++ b/packages/bbui/src/ProgressBar/ProgressBar.svelte @@ -8,6 +8,8 @@ export let duration = 1000 export let width = false export let sideLabel = false + export let hidePercentage = true + export let color // red, green, default = blue export let size = "M" @@ -37,7 +39,7 @@ {/if} - {#if value || value === 0} + {#if !hidePercentage && (value || value === 0)}
@@ -47,8 +49,19 @@
+ + diff --git a/packages/server/src/api/controllers/application.ts b/packages/server/src/api/controllers/application.ts index 57a18e7df3..7183c083ef 100644 --- a/packages/server/src/api/controllers/application.ts +++ b/packages/server/src/api/controllers/application.ts @@ -443,7 +443,6 @@ const destroyApp = async (ctx: any) => { const result = await db.destroy() if (isUnpublish) { - await quotas.removePublishedApp() await events.app.unpublished(app) } else { await quotas.removeApp() diff --git a/packages/server/src/api/controllers/deploy/index.ts b/packages/server/src/api/controllers/deploy/index.ts index 7c1a093398..680f2d534e 100644 --- a/packages/server/src/api/controllers/deploy/index.ts +++ b/packages/server/src/api/controllers/deploy/index.ts @@ -188,12 +188,7 @@ const _deployApp = async function (ctx: any) { console.log("Deploying app...") - let app - if (await isFirstDeploy()) { - app = await quotas.addPublishedApp(() => deployApp(deployment)) - } else { - app = await deployApp(deployment) - } + let app = await deployApp(deployment) await events.app.published(app) ctx.body = deployment diff --git a/packages/server/src/migrations/functions/backfill/global.ts b/packages/server/src/migrations/functions/backfill/global.ts index 5dd812d6ea..7c8558c2df 100644 --- a/packages/server/src/migrations/functions/backfill/global.ts +++ b/packages/server/src/migrations/functions/backfill/global.ts @@ -35,12 +35,10 @@ const formatUsage = (usage: QuotaUsage) => { let maxAutomations = 0 let maxQueries = 0 let rows = 0 - let developers = 0 if (usage) { if (usage.usageQuota) { rows = usage.usageQuota.rows - developers = usage.usageQuota.developers } if (usage.monthly) { @@ -59,7 +57,6 @@ const formatUsage = (usage: QuotaUsage) => { maxAutomations, maxQueries, rows, - developers, } } diff --git a/packages/server/src/migrations/functions/developerQuota.ts b/packages/server/src/migrations/functions/developerQuota.ts deleted file mode 100644 index b639e0bd83..0000000000 --- a/packages/server/src/migrations/functions/developerQuota.ts +++ /dev/null @@ -1,15 +0,0 @@ -const { createUserBuildersView } = require("@budibase/backend-core/db") -import * as syncDevelopers from "./usageQuotas/syncDevelopers" - -/** - * Date: - * March 2022 - * - * Description: - * Create the builder users view and sync the developer count - */ - -export const run = async (db: any) => { - await createUserBuildersView(db) - await syncDevelopers.run() -} diff --git a/packages/server/src/migrations/functions/publishedAppsQuota.ts b/packages/server/src/migrations/functions/publishedAppsQuota.ts deleted file mode 100644 index 53bd8e65e5..0000000000 --- a/packages/server/src/migrations/functions/publishedAppsQuota.ts +++ /dev/null @@ -1,13 +0,0 @@ -import * as syncPublishedApps from "./usageQuotas/syncPublishedApps" - -/** - * Date: - * March 2022 - * - * Description: - * Sync the published apps count - */ - -export const run = async (db: any) => { - await syncPublishedApps.run() -} diff --git a/packages/server/src/migrations/functions/usageQuotas/syncDevelopers.ts b/packages/server/src/migrations/functions/usageQuotas/syncDevelopers.ts deleted file mode 100644 index c13a095b23..0000000000 --- a/packages/server/src/migrations/functions/usageQuotas/syncDevelopers.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { getTenantId } from "@budibase/backend-core/tenancy" -import { utils } from "@budibase/backend-core" -import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro" - -export const run = async () => { - // get developer count - const developerCount = await utils.getBuildersCount() - - // sync developer count - const tenantId = getTenantId() - console.log( - `[Tenant: ${tenantId}] Syncing developer count: ${developerCount}` - ) - await quotas.setUsage( - developerCount, - StaticQuotaName.DEVELOPERS, - QuotaUsageType.STATIC - ) -} diff --git a/packages/server/src/migrations/functions/usageQuotas/syncPublishedApps.ts b/packages/server/src/migrations/functions/usageQuotas/syncPublishedApps.ts deleted file mode 100644 index 550a3006b3..0000000000 --- a/packages/server/src/migrations/functions/usageQuotas/syncPublishedApps.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { getTenantId } from "@budibase/backend-core/tenancy" -import { getAllApps } from "@budibase/backend-core/db" -import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro" - -export const run = async () => { - // get app count - const opts: any = { dev: false } - const prodApps = await getAllApps(opts) - const prodAppCount = prodApps ? prodApps.length : 0 - - // sync app count - const tenantId = getTenantId() - console.log( - `[Tenant: ${tenantId}] Syncing published app count: ${prodAppCount}` - ) - await quotas.setUsage( - prodAppCount, - StaticQuotaName.PUBLISHED_APPS, - QuotaUsageType.STATIC - ) -} diff --git a/packages/server/src/migrations/index.ts b/packages/server/src/migrations/index.ts index 494740d1d9..bb691f1133 100644 --- a/packages/server/src/migrations/index.ts +++ b/packages/server/src/migrations/index.ts @@ -6,8 +6,6 @@ import env from "../environment" import * as userEmailViewCasing from "./functions/userEmailViewCasing" import * as quota1 from "./functions/quotas1" import * as appUrls from "./functions/appUrls" -import * as developerQuota from "./functions/developerQuota" -import * as publishedAppsQuota from "./functions/publishedAppsQuota" import * as backfill from "./functions/backfill" /** @@ -42,20 +40,6 @@ export const buildMigrations = () => { }) break } - case MigrationName.DEVELOPER_QUOTA: { - serverMigrations.push({ - ...definition, - fn: developerQuota.run, - }) - break - } - case MigrationName.PUBLISHED_APP_QUOTA: { - serverMigrations.push({ - ...definition, - fn: publishedAppsQuota.run, - }) - break - } case MigrationName.EVENT_APP_BACKFILL: { serverMigrations.push({ ...definition, diff --git a/packages/types/src/sdk/migrations.ts b/packages/types/src/sdk/migrations.ts index bb32d2e045..3ad4daccaf 100644 --- a/packages/types/src/sdk/migrations.ts +++ b/packages/types/src/sdk/migrations.ts @@ -41,8 +41,6 @@ export enum MigrationName { USER_EMAIL_VIEW_CASING = "user_email_view_casing", QUOTAS_1 = "quotas_1", APP_URLS = "app_urls", - DEVELOPER_QUOTA = "developer_quota", - PUBLISHED_APP_QUOTA = "published_apps_quota", EVENT_APP_BACKFILL = "event_app_backfill", EVENT_GLOBAL_BACKFILL = "event_global_backfill", EVENT_INSTALLATION_BACKFILL = "event_installation_backfill", diff --git a/packages/worker/src/sdk/users/users.ts b/packages/worker/src/sdk/users/users.ts index 8e9b3382e4..5355b82b72 100644 --- a/packages/worker/src/sdk/users/users.ts +++ b/packages/worker/src/sdk/users/users.ts @@ -1,5 +1,4 @@ import env from "../../environment" -import { quotas } from "@budibase/pro" import * as apps from "../../utilities/appService" import * as eventHelpers from "./events" import { @@ -164,15 +163,7 @@ export const save = async ( return putOpts } // save the user to db - let response - const putUserFn = () => { - return db.put(user) - } - if (eventHelpers.isAddingBuilder(user, dbUser)) { - response = await quotas.addDeveloper(putUserFn) - } else { - response = await putUserFn() - } + let response = await db.put(user) user._rev = response.rev await eventHelpers.handleSaveEvents(user, dbUser) @@ -223,7 +214,6 @@ export const destroy = async (id: string, currentUser: any) => { await deprovisioning.removeUserFromInfoDB(dbUser) await db.remove(dbUser._id, dbUser._rev) await eventHelpers.handleDeleteEvents(dbUser) - await quotas.removeUser(dbUser) await cache.user.invalidateUser(dbUser._id) await sessions.invalidateSessions(dbUser._id) // let server know to sync user