The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix top links implementation cron
Steven Tey24066da79f0e
diff --git a/apps/web/app/api/cron/usage/utils.ts b/apps/web/app/api/cron/usage/utils.tsindex 9b991050a7..32b9849431 100644--- a/apps/web/app/api/cron/usage/utils.ts+++ b/apps/web/app/api/cron/usage/utils.ts@@ -118,52 +118,28 @@ export const updateUsage = async () => {const topFive = data.slice(0, 5);const topFiveLinkIds = topFive.map(({ link }) => link);- const [links, domains] = await Promise.all([- prisma.link.findMany({- where: {- projectId: workspace.id,- id: {- in: topFiveLinkIds,- },- },- select: {- id: true,- domain: true,- key: true,- },- }),- prisma.domain.findMany({- where: {- projectId: workspace.id,- id: {- in: topFiveLinkIds,- },- },- select: {- id: true,- slug: true,+ const links = await prisma.link.findMany({+ where: {+ projectId: workspace.id,+ id: {+ in: topFiveLinkIds,},+ },+ select: {+ id: true,+ domain: true,+ key: true,+ },+ });++ const allLinks = links.map((link) => ({+ id: link.id,+ shortLink: linkConstructor({+ domain: link.domain,+ key: link.key,+ pretty: true,}),- ]);-- const allLinks = [- ...links.map((link) => ({- id: link.id,- shortLink: linkConstructor({- domain: link.domain,- key: link.key,- pretty: true,- }),- })),- ...domains.map((domain) => ({- id: domain.id,- shortLink: linkConstructor({- domain: domain.slug,- key: "_root",- pretty: true,- }),- })),- ];+ }));return topFive.map((d) => ({link: allLinks.find((l) => l.id === d.link)?.shortLink || "",