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.

record lastClicked

Steven Teyb36ee5791e18
diff --git a/lib/tinybird.ts b/lib/tinybird.ts
index d869b39a99..bf76394284 100644
--- a/lib/tinybird.ts
+++ b/lib/tinybird.ts
@@ -56,7 +56,7 @@ export async function recordClick(
...(key && conn
? [
conn.execute(
- "UPDATE Link SET clicks = clicks + 1 WHERE domain = ? AND `key` = ?",
+ "UPDATE Link SET clicks = clicks + 1, lastClicked = NOW() WHERE domain = ? AND `key` = ?",
[domain, key],
),
conn.execute(
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index 292a985a1a..07739e6c78 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -192,9 +192,9 @@ model Link {
// Relational reference to the project domain
projectDomain Domain? @relation(fields: [domain], references: [slug], onUpdate: Cascade, onDelete: Cascade)
- // Link metadata
- clicks Int @default(0) // number of clicks
publicStats Boolean @default(false) // whether to show public stats or not
+ clicks Int @default(0) // number of clicks
+ lastClicked DateTime? // when the link was last clicked
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt