Skip to content

Commit 75cb870

Browse files
committed
fix(webapp): use the platform limit for schedules instead of computing base + purchased
1 parent 308bdc4 commit 75cb870

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

apps/webapp/app/presenters/v3/ScheduleListPresenter.server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,17 @@ export class ScheduleListPresenter extends BasePresenter {
103103
projectId,
104104
});
105105

106-
const baseLimit = await getLimit(project.organizationId, "schedules", 100_000_000);
106+
const limit = await getLimit(project.organizationId, "schedules", 100_000_000);
107107
const [currentPlan, plans] = await Promise.all([
108108
getCurrentPlan(project.organizationId),
109109
getPlans(),
110110
]);
111111

112112
const extraSchedules = currentPlan?.v3Subscription?.addOns?.schedules?.purchased ?? 0;
113-
const limit = baseLimit + extraSchedules;
114113
const canPurchaseSchedules =
115114
currentPlan?.v3Subscription?.plan?.limits.schedules.canExceed === true;
116115
const maxScheduleQuota = currentPlan?.v3Subscription?.addOns?.schedules?.quota ?? 0;
117-
const planScheduleLimit = currentPlan?.v3Subscription?.plan?.limits.schedules.number ?? 0;
116+
const planScheduleLimit = limit - extraSchedules;
118117
const schedulePricing = plans?.addOnPricing.schedules ?? null;
119118

120119
const purchaseInfo = {

apps/webapp/app/v3/services/checkSchedule.server.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ZodError } from "zod";
22
import { CronPattern } from "../schedules";
33
import { BaseService, ServiceValidationError } from "./baseService.server";
4-
import { getCurrentPlan, getLimit } from "~/services/platform.v3.server";
4+
import { getLimit } from "~/services/platform.v3.server";
55
import { getTimezones } from "~/utils/timezones.server";
66
import { env } from "~/env.server";
77
import { type PrismaClientOrTransaction, type RuntimeEnvironmentType } from "@trigger.dev/database";
@@ -89,11 +89,7 @@ export class CheckScheduleService extends BaseService {
8989

9090
//if creating a schedule, check they're under the limits
9191
if (!schedule.friendlyId) {
92-
const baseLimit = await getLimit(project.organizationId, "schedules", 100_000_000);
93-
const currentPlan = await getCurrentPlan(project.organizationId);
94-
const purchasedSchedules =
95-
currentPlan?.v3Subscription?.addOns?.schedules?.purchased ?? 0;
96-
const limit = baseLimit + purchasedSchedules;
92+
const limit = await getLimit(project.organizationId, "schedules", 100_000_000);
9793
const schedulesCount = await CheckScheduleService.getUsedSchedulesCount({
9894
prisma: this._prisma,
9995
projectId,

0 commit comments

Comments
 (0)