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 broken e2e tag

Steven Tey8d2ad1bdb149
diff --git a/apps/web/scripts/fix-broken-link-tags.ts b/apps/web/scripts/fix-broken-link-tags.ts
new file mode 100644
index 0000000000..beb7b8c971
--- /dev/null
+++ b/apps/web/scripts/fix-broken-link-tags.ts
@@ -0,0 +1,45 @@
+import { prisma } from "@dub/prisma";
+import "dotenv-flow/config";
+
+async function main() {
+ const linkTags = await prisma.link.findMany({
+ where: {
+ projectId: "clrei1gld0002vs9mzn93p8ik",
+ },
+ include: {
+ tags: true,
+ },
+ orderBy: {
+ createdAt: "desc",
+ },
+ });
+
+ const tagIds = linkTags.flatMap((link) => link.tags.map((tag) => tag.tagId));
+
+ const tags = await prisma.tag.findMany({
+ where: {
+ id: { in: tagIds },
+ },
+ });
+ const tagsThatDontExist = tagIds.filter(
+ (tagId) => !tags.some((tag) => tag.id === tagId),
+ );
+
+ const linksForTagsThatDontExist = await prisma.link.findMany({
+ where: {
+ tags: {
+ some: { tagId: { in: tagsThatDontExist } },
+ },
+ },
+ });
+
+ const deleteLinks = await prisma.link.deleteMany({
+ where: {
+ id: { in: linksForTagsThatDontExist.map((link) => link.id) },
+ },
+ });
+
+ console.log({ tagsThatDontExist, linksForTagsThatDontExist, deleteLinks });
+}
+
+main();
diff --git a/apps/web/tests/utils/resource.ts b/apps/web/tests/utils/resource.ts
index 28a3c2661f..b8376834d5 100644
--- a/apps/web/tests/utils/resource.ts
+++ b/apps/web/tests/utils/resource.ts
@@ -13,7 +13,7 @@ export const E2E_TAG = {
};
export const E2E_TAG_2 = {
- id: "tag_8eyd9MfjUCCkRnGDt1hbe4v3",
+ id: "tag_sfaXFOt0kFLtEV3Z5wtywbTl",
name: "E2E Tests 2 (DO NOT DELETE)",
color: "blue",
};