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.

update script

Steven Tey85b943b67542
diff --git a/apps/web/scripts/partners/invalidate-partner-links.ts b/apps/web/scripts/partners/invalidate-partner-links.ts
new file mode 100644
index 0000000000..dea1af8bd6
--- /dev/null
+++ b/apps/web/scripts/partners/invalidate-partner-links.ts
@@ -0,0 +1,28 @@
+import { prisma } from "@dub/prisma";
+import "dotenv-flow/config";
+import { linkCache } from "../../lib/api/links/cache";
+
+// one time script to invalidate partner links
+async function main() {
+ const links = await prisma.link.findMany({
+ where: {
+ programId: {
+ not: null,
+ },
+ partnerId: {
+ not: null,
+ },
+ // last clicked within the last 24 hours (would've been cached)
+ lastClicked: {
+ gte: new Date(Date.now() - 24 * 60 * 60 * 1000),
+ },
+ },
+ skip: 0,
+ take: 200,
+ });
+
+ const res = await linkCache.expireMany(links);
+ console.log(res);
+}
+
+main();
diff --git a/apps/web/scripts/reset-partner-country.ts b/apps/web/scripts/reset-partner-country.ts
deleted file mode 100644
index 515e50cbd8..0000000000
--- a/apps/web/scripts/reset-partner-country.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { prisma } from "@dub/prisma";
-import "dotenv-flow/config";
-
-// one time script to reset partner countries for programs that imported from another platform
-// probably won't need it in the future
-async function main() {
- const partners = await prisma.partner.updateMany({
- where: {
- country: "US",
- programs: {
- some: {
- programId: "xxx",
- },
- },
- users: {
- none: {},
- },
- },
- data: {
- country: null,
- },
- });
- console.log(partners);
-}
-
-main();