Skip to content

Commit

Permalink
fix: 2.2 data migration for self-hosters (formbricks#2792)
Browse files Browse the repository at this point in the history
  • Loading branch information
pandeymangg authored Jun 20, 2024
1 parent 17279cb commit 8aedbde
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { IS_FORMBRICKS_CLOUD } from "@formbricks/lib/constants";
import { getEnvironment, getEnvironments } from "@formbricks/lib/environment/service";
import { getMembershipByUserIdOrganizationId } from "@formbricks/lib/membership/service";
import {
getMonthlyActiveOrganizationPeopleCount,
getMonthlyOrganizationResponseCount,
getOrganizationByEnvironmentId,
getOrganizationsByUserId,
} from "@formbricks/lib/organization/service";
Expand Down Expand Up @@ -48,22 +46,11 @@ export const EnvironmentLayout = async ({ environmentId, session, children }: En
const currentProductChannel =
products.find((product) => product.id === environment.productId)?.config.channel ?? null;

const [peopleCount, responseCount] = await Promise.all([
getMonthlyActiveOrganizationPeopleCount(organization.id),
getMonthlyOrganizationResponseCount(organization.id),
]);

return (
<div className="flex h-screen min-h-screen flex-col overflow-hidden">
<DevEnvironmentBanner environment={environment} />

{IS_FORMBRICKS_CLOUD && (
<LimitsReachedBanner
organization={organization}
peopleCount={peopleCount}
responseCount={responseCount}
/>
)}
{IS_FORMBRICKS_CLOUD && <LimitsReachedBanner organization={organization} />}

<div className="flex h-full">
<MainNavigation
Expand Down
2 changes: 1 addition & 1 deletion packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"data-migration:v2.1": "pnpm data-migration:extended-noCodeActions",
"data-migration:adds_app_and_website_status_indicator": "ts-node ./data-migrations/20240610055828_adds_app_and_website_status_indicators/data-migration.ts",
"data-migration:product-config": "ts-node ./data-migrations/20240612115151_adds_product_config/data-migration.ts",
"data-migration:v2.2": "pnpm data-migration:adds_app_and_website_status_indicator && pnpm data-migration:product-config"
"data-migration:v2.2": "pnpm data-migration:adds_app_and_website_status_indicator && pnpm data-migration:product-config && pnpm data-migration:pricing-v2"
},
"dependencies": {
"@prisma/client": "^5.15.1",
Expand Down
17 changes: 10 additions & 7 deletions packages/ui/LimitsReachedBanner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import Link from "next/link";
import {
getMonthlyActiveOrganizationPeopleCount,
getMonthlyOrganizationResponseCount,
} from "@formbricks/lib/organization/service";
import { TOrganization } from "@formbricks/types/organizations";

interface LimitsReachedBannerProps {
organization: TOrganization;
peopleCount: number;
responseCount: number;
}

export const LimitsReachedBanner = ({
organization,
peopleCount,
responseCount,
}: LimitsReachedBannerProps) => {
export const LimitsReachedBanner = async ({ organization }: LimitsReachedBannerProps) => {
const [peopleCount, responseCount] = await Promise.all([
getMonthlyActiveOrganizationPeopleCount(organization.id),
getMonthlyOrganizationResponseCount(organization.id),
]);

const orgBillingPeopleLimit = organization.billing?.limits?.monthly?.miu;
const orgBillingResponseLimit = organization.billing?.limits?.monthly?.responses;

Expand Down

0 comments on commit 8aedbde

Please sign in to comment.