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.

fix plain callback

Steven Teyf3f9e2e425a1
diff --git a/apps/web/app/api/callback/plain/route.ts b/apps/web/app/api/callback/plain/route.ts
index 8fb41bc2ea..0536cb09c0 100644
--- a/apps/web/app/api/callback/plain/route.ts
+++ b/apps/web/app/api/callback/plain/route.ts
@@ -79,7 +79,6 @@ export async function POST(req: NextRequest) {
include: {
_count: {
select: {
- links: true,
domains: true,
tags: true,
users: true,
@@ -116,12 +115,14 @@ export async function POST(req: NextRequest) {
plan,
usage,
usageLimit,
+ totalClicks,
linksUsage,
linksLimit,
+ totalLinks,
domainsLimit,
tagsLimit,
usersLimit,
- _count: { links, domains, tags, users },
+ _count: { domains, tags, users },
} = topWorkspace;
if (plainCustomer.data) {
@@ -225,7 +226,17 @@ export async function POST(req: NextRequest) {
},
},
plainUsageSection({
- usage: links,
+ usage: totalClicks,
+ label: "Total Clicks",
+ color: "GREEN",
+ }),
+ {
+ componentSpacer: {
+ spacerSize: "M",
+ },
+ },
+ plainUsageSection({
+ usage: totalLinks,
label: "Total Links",
color: "YELLOW",
}),
diff --git a/apps/web/scripts/buffer/delete-old-links.ts b/apps/web/scripts/buffer/delete-old-links.ts
new file mode 100644
index 0000000000..4ca9c89b7b
--- /dev/null
+++ b/apps/web/scripts/buffer/delete-old-links.ts
@@ -0,0 +1,54 @@
+import { prisma } from "@dub/prisma";
+import { Prisma } from "@dub/prisma/client";
+import "dotenv-flow/config";
+
+async function main() {
+ const where: Prisma.LinkWhereInput = {
+ projectId: "xxx",
+ archived: false,
+ folderId: "xxx",
+ AND: [
+ {
+ createdAt: {
+ lte: new Date("2025-02-15T15:27:00.000Z"),
+ },
+ },
+ {
+ createdAt: {
+ gte: new Date("2025-01-29T14:27:00.000Z"),
+ },
+ },
+ ],
+ };
+
+ const links = await prisma.link.findMany({
+ where,
+ select: {
+ id: true,
+ shortLink: true,
+ },
+ take: 1000,
+ orderBy: {
+ createdAt: "asc",
+ },
+ });
+
+ if (!links.length) {
+ console.log("No more links to migrate.");
+ return;
+ }
+
+ console.table(links);
+
+ await prisma.link.deleteMany({
+ where: {
+ id: {
+ in: links.map((link) => link.id),
+ },
+ },
+ });
+
+ console.log(`Deleted ${links.length} links`);
+}
+
+main();