Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

small updates

Steven Tey19928582e2b8
diff --git a/apps/web/scripts/update-payouts-limits.ts b/apps/web/scripts/update-payouts-limits.ts
index d29f6ec5da..2ebceaf6a3 100644
--- a/apps/web/scripts/update-payouts-limits.ts
+++ b/apps/web/scripts/update-payouts-limits.ts
@@ -1,81 +1,33 @@
import { prisma } from "@dub/prisma";
-import { getFirstAndLastDay } from "@dub/utils";
import "dotenv-flow/config";
+import * as fs from "fs";
+import * as Papa from "papaparse";
-async function main() {
- // const workspaces = await prisma.project.updateMany({
- // where: {
- // plan: {
- // startsWith: "business",
- // },
- // },
- // data: {
- // payoutsLimit: 2_500_00,
- // },
- // });
-
- // console.table(workspaces);
+const stripeIds: string[] = [];
- // workspace with payouts in the last 30 days
- const workspaceWithPayouts = await prisma.invoice.groupBy({
- by: ["workspaceId"],
- where: {
- createdAt: {
- gte: new Date(new Date().setDate(new Date().getDate() - 30)),
- },
- },
- _sum: {
- amount: true,
+async function main() {
+ Papa.parse(fs.createReadStream("business_monthly.csv", "utf-8"), {
+ header: true,
+ step: (result: { data: any }) => {
+ stripeIds.push(result.data["Customer ID"]);
},
- });
-
- console.table(workspaceWithPayouts);
-
- const res = await Promise.all(
- workspaceWithPayouts.map(async (w) => {
- if (!w.workspaceId) {
- return;
- }
-
- const workspace = await prisma.project.findUnique({
- where: { id: w.workspaceId },
- });
-
- if (!workspace) {
- return;
- }
-
- const { firstDay } = getFirstAndLastDay(workspace.billingCycleStart);
-
- const invoices = await prisma.invoice.aggregate({
+ complete: async () => {
+ const res = await prisma.project.updateMany({
where: {
- workspaceId: workspace.id,
- createdAt: {
- gte: firstDay,
+ // plan: "business",
+ stripeId: {
+ in: stripeIds,
},
},
- _sum: {
- amount: true,
- },
- });
-
- await prisma.project.update({
- where: { id: workspace.id },
data: {
- payoutsUsage: invoices._sum.amount ?? 0,
+ // payoutsLimit: 0,
+ payoutsLimit: 2_500_00,
},
});
- return {
- workspaceId: workspace.id,
- workspaceName: workspace.name,
- payoutsUsage: invoices._sum.amount,
- payoutsLimit: workspace.payoutsLimit,
- };
- }),
- );
-
- console.table(res);
+ console.log({ res });
+ },
+ });
}
main();
diff --git a/packages/utils/src/constants/pricing.tsx b/packages/utils/src/constants/pricing.tsx
index 7407113455..bdacade187 100644
--- a/packages/utils/src/constants/pricing.tsx
+++ b/packages/utils/src/constants/pricing.tsx
@@ -43,7 +43,7 @@ export const PLANS = [
},
limits: {
links: 25,
- clicks: 1000,
+ clicks: 1_000,
payouts: 0,
domains: 3,
tags: 5,
@@ -77,7 +77,7 @@ export const PLANS = [
tags: 25,
folders: 3,
users: 3,
- ai: 1000,
+ ai: 1_000,
api: 600,
retention: "1-year",
},
@@ -157,8 +157,8 @@ export const PLANS = [
tags: INFINITY_NUMBER,
folders: 20,
users: 10,
- ai: 1000,
- api: 1200,
+ ai: 1_000,
+ api: 1_200,
retention: "3-year",
},
featureTitle: "Everything in Pro, plus:",
@@ -254,8 +254,8 @@ export const PLANS = [
tags: INFINITY_NUMBER,
folders: 50,
users: 20,
- ai: 1000,
- api: 3000,
+ ai: 1_000,
+ api: 3_000,
retention: "5-year",
},
featureTitle: "Everything in Business, plus:",
@@ -319,15 +319,15 @@ export const PLANS = [
yearly: null,
},
limits: {
- links: 250000,
- clicks: 5000000,
+ links: 500_000,
+ clicks: 5_000_000,
payouts: INFINITY_NUMBER,
- domains: 1000,
+ domains: 250,
tags: INFINITY_NUMBER,
folders: INFINITY_NUMBER,
- users: 500,
- ai: 10000,
- api: 10000,
+ users: 30,
+ ai: 1_000,
+ api: 3_000,
retention: "Unlimited",
},
},