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.

improve script efficiency

Steven Teycabb58581cd1
diff --git a/apps/web/scripts/sync-link-tags.ts b/apps/web/scripts/sync-link-tags.ts
index 9fcf0671c6..aa702eb8eb 100644
--- a/apps/web/scripts/sync-link-tags.ts
+++ b/apps/web/scripts/sync-link-tags.ts
@@ -1,4 +1,5 @@
import prisma from "@/lib/prisma";
+import { DUB_PROJECT_ID } from "@dub/utils";
import "dotenv-flow/config";
/**
@@ -19,28 +20,14 @@ async function main() {
console.log(`Updating ${links.length} links...`);
- // const all = await Promise.allSettled(
- // links.map(async (link) => {
- // if (link.tagId == null) return;
-
- // await prisma.link.update({
- // where: {
- // id: link.id,
- // },
- // data: {
- // tags: {
- // create: {
- // tagId: link.tagId,
- // },
- // },
- // },
- // });
- // }),
- // );
-
- // const updated = all.filter(({ status }) => status === "fulfilled");
+ const response = await prisma.linkTag.createMany({
+ data: links.map((link) => ({
+ linkId: link.id,
+ tagId: link.tagId!, // cause we filtered out links without tagId
+ })),
+ });
- // console.log(`Updated ${updated.length} / ${links.length} links.`);
+ console.log(`Created ${response.count} LinkTag records`);
}
main();