The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fixed edge case
Steven Teyf6a48d60e723
diff --git a/apps/web/app/api/cron/import/short/utils.ts b/apps/web/app/api/cron/import/short/utils.tsindex b4bcc06e64..3695493a6a 100644--- a/apps/web/app/api/cron/import/short/utils.ts+++ b/apps/web/app/api/cron/import/short/utils.ts@@ -79,12 +79,24 @@ export const importLinksFromShort = async ({// import tags into databaseif (importTags && tagsToCreate.size > 0) {- await prisma.tag.createMany({- data: Array.from(tagsToCreate).map((tag) => ({- name: tag,- color: randomBadgeColor(),+ const existingTags = await prisma.tag.findMany({+ where: {projectId,- })),+ },+ select: {+ id: true,+ name: true,+ },+ });+ await prisma.tag.createMany({+ data: Array.from(tagsToCreate)+ // filter out existing tags with the same name+ .filter((tag) => !existingTags.some((t) => t.name === tag))+ .map((tag) => ({+ name: tag,+ color: randomBadgeColor(),+ projectId,+ })),skipDuplicates: true,});allTags = await prisma.tag.findMany({