diff --git a/apps/webapp/app/components/billing/ConcurrentRunsChart.tsx b/apps/webapp/app/components/billing/ConcurrentRunsChart.tsx
index 047391a00..06611e7b4 100644
--- a/apps/webapp/app/components/billing/ConcurrentRunsChart.tsx
+++ b/apps/webapp/app/components/billing/ConcurrentRunsChart.tsx
@@ -35,7 +35,6 @@ export function ConcurrentRunsChart({
}) {
return (
-
Concurrent Runs
{!hasConcurrencyData && (
No concurrent Runs to show
@@ -52,20 +51,33 @@ export function ConcurrentRunsChart({
}}
className="-ml-8"
>
-
+
{concurrentRunsLimit && (
}
stroke="#F43F5E"
- color="#fff"
+ color="#F43F5E"
strokeWidth={1}
strokeDasharray={5}
ifOverflow="extendDomain"
className="text-xs"
- />
+ >
+
+
)}
);
}
-
-function ReferenceLineLabel({ y }: { y: number }) {
- return (
-
-
- Concurrency limit
-
-
- );
-}
diff --git a/apps/webapp/app/presenters/OrgUsagePresenter.server.ts b/apps/webapp/app/presenters/OrgUsagePresenter.server.ts
index 1f398cd45..c53e3ff58 100644
--- a/apps/webapp/app/presenters/OrgUsagePresenter.server.ts
+++ b/apps/webapp/app/presenters/OrgUsagePresenter.server.ts
@@ -28,11 +28,6 @@ export class OrgUsagePresenter {
return;
}
- const startOfMonth = new Date(new Date().getFullYear(), new Date().getMonth(), 1);
- const startOfLastMonth = new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1); // this works for January as well
- const endOfMonth = new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1);
- endOfMonth.setDate(endOfMonth.getDate() - 1);
-
// Get count of runs since the start of the current month
const runsCount = await this.#prismaClient.jobRun.count({
where: {
@@ -44,18 +39,6 @@ export class OrgUsagePresenter {
},
});
- // Get the count of runs for last month
- const runsCountLastMonth = await this.#prismaClient.jobRun.count({
- where: {
- organizationId: organization.id,
- createdAt: {
- gte: startOfLastMonth,
- lt: startOfMonth,
- },
- internal: false,
- },
- });
-
// Get the count of the runs for the last 6 months, by month. So for example we want the data shape to be:
// [
// { month: "2021-01", count: 10 },
@@ -82,45 +65,6 @@ export class OrgUsagePresenter {
const monthlyRunsDataDisplay = fillInMissingRunMonthlyData(monthlyRunsData, 6);
- const totalJobs = await this.#prismaClient.job.count({
- where: {
- organizationId: organization.id,
- internal: false,
- },
- });
-
- const totalJobsLastMonth = await this.#prismaClient.job.count({
- where: {
- organizationId: organization.id,
- createdAt: {
- lt: startOfMonth,
- },
- deletedAt: null,
- internal: false,
- },
- });
-
- const totalIntegrations = await this.#prismaClient.integration.count({
- where: {
- organizationId: organization.id,
- },
- });
-
- const totalIntegrationsLastMonth = await this.#prismaClient.integration.count({
- where: {
- organizationId: organization.id,
- createdAt: {
- lt: startOfMonth,
- },
- },
- });
-
- const totalMembers = await this.#prismaClient.orgMember.count({
- where: {
- organizationId: organization.id,
- },
- });
-
// Max concurrency each day over past 30 days
const concurrencyChartRawData = await this.#prismaClient.$queryRaw<
{ day: Date; max_concurrent_runs: BigInt }[]
@@ -173,6 +117,8 @@ export class OrgUsagePresenter {
concurrencyChartRawData
);
+ const endOfMonth = new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1);
+ endOfMonth.setDate(endOfMonth.getDate() - 1);
const projectedRunsCount = Math.round(
runsCount / (new Date().getDate() / endOfMonth.getDate())
);
@@ -202,16 +148,10 @@ export class OrgUsagePresenter {
id: organization.id,
runsCount,
projectedRunsCount,
- runsCountLastMonth,
monthlyRunsData: monthlyRunsDataDisplay,
hasMonthlyRunData,
concurrencyData: concurrencyChartRawDataFilledIn,
hasConcurrencyData,
- totalJobs,
- totalJobsLastMonth,
- totalIntegrations,
- totalIntegrationsLastMonth,
- totalMembers,
runCostEstimation,
projectedRunCostEstimation,
};
@@ -260,15 +200,21 @@ function fillInMissingConcurrencyDays(
for (let i = 0; i < days; i++) {
const date = new Date(startDate);
date.setDate(date.getDate() + i);
+
+ let formattedDate = `${date.getDate()}`;
+ if (date.getDate() === 1) {
+ formattedDate = dateFormatter.format(date);
+ }
+
const foundData = data.find((d) => d.day.toISOString() === date.toISOString());
if (!foundData) {
outputData.push({
- name: dateFormatter.format(date),
+ name: formattedDate,
maxConcurrentRuns: 0,
});
} else {
outputData.push({
- name: dateFormatter.format(date),
+ name: formattedDate,
maxConcurrentRuns: Number(foundData.max_concurrent_runs),
});
}
@@ -302,11 +248,3 @@ function getMonthsBetween(startMonth: string, endMonth: string): string[] {
return result;
}
-
-function getLastSecondOfMonth(endMonth: string) {
- const [year, month] = endMonth.split("-").map(Number);
- const nextMonthFirstDay = new Date(year, month, 1);
- nextMonthFirstDay.setDate(0);
- nextMonthFirstDay.setHours(23, 59, 59);
- return nextMonthFirstDay;
-}
diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing._index/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing._index/route.tsx
index cf0f2cbd4..5a0c0ce48 100644
--- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing._index/route.tsx
+++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing._index/route.tsx
@@ -188,78 +188,6 @@ export default function Page() {
-
-
-
- Total Runs this month
-
-
-
-
{loaderData.runsCount.toLocaleString()}
-
- {loaderData.runsCountLastMonth} Runs last month
-
-
-
-
-
- Total Jobs
-
-
-
-
{loaderData.totalJobs.toLocaleString()}
-
- {loaderData.totalJobs === loaderData.totalJobsLastMonth ? (
- <>No change since last month>
- ) : loaderData.totalJobs > loaderData.totalJobsLastMonth ? (
- <>+{loaderData.totalJobs - loaderData.totalJobsLastMonth} since last month>
- ) : (
- <>-{loaderData.totalJobsLastMonth - loaderData.totalJobs} since last month>
- )}
-
-
-
-
-
- Total Integrations
-
-
-
-
{loaderData.totalIntegrations.toLocaleString()}
-
- {loaderData.totalIntegrations === loaderData.totalIntegrationsLastMonth ? (
- <>No change since last month>
- ) : loaderData.totalIntegrations > loaderData.totalIntegrationsLastMonth ? (
- <>
- +{loaderData.totalIntegrations - loaderData.totalIntegrationsLastMonth} since last
- month
- >
- ) : (
- <>
- -{loaderData.totalIntegrationsLastMonth - loaderData.totalIntegrations} since last
- month
- >
- )}
-
-
-
-
-
- Team members
-
-
-
-
{loaderData.totalMembers.toLocaleString()}
-
- Manage
-
-
-
-
-
);
}
diff --git a/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing/route.tsx b/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing/route.tsx
index e55ccdc7f..c732684ed 100644
--- a/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing/route.tsx
+++ b/apps/webapp/app/routes/_app.orgs.$organizationSlug.billing/route.tsx
@@ -29,12 +29,6 @@ import { OrganizationParamsSchema, plansPath, usagePath } from "~/utils/pathBuil
import { useCurrentPlan } from "../_app.orgs.$organizationSlug/route";
import { ActiveSubscription } from "@trigger.dev/billing";
-export async function loader({ params, request }: LoaderFunctionArgs) {
- const userId = await requireUserId(request);
- const { organizationSlug } = OrganizationParamsSchema.parse(params);
- return typedjson({});
-}
-
export const handle: Handle = {
breadcrumb: (match) => ,
};
@@ -74,16 +68,16 @@ export default function Page() {
{isManagedCloud && (
<>
- {/* {stripePortalLink && (
+ {currentPlan?.subscription?.isPaying && (
<>
-
+ {/*
Invoices
Manage card details
-
+ */}
>
- )} */}
+ )}