Skip to content

Commit eff02dd

Browse files
committed
add scripts
1 parent db2297b commit eff02dd

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { prisma } from "@dub/prisma";
2+
import "dotenv-flow/config";
3+
import { linkCache } from "../lib/api/links/cache";
4+
5+
// script to backfill link cache for links with webhooks
6+
async function main() {
7+
const links = await prisma.link.findMany({
8+
where: {
9+
webhooks: {
10+
some: {},
11+
},
12+
},
13+
include: {
14+
webhooks: true,
15+
},
16+
});
17+
18+
console.log(links.length);
19+
console.log(JSON.stringify(links, null, 2));
20+
21+
const res = await linkCache.mset(links);
22+
console.log(res);
23+
}
24+
25+
main();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { prisma } from "@dub/prisma";
2+
import "dotenv-flow/config";
3+
import { redis } from "../lib/upstash";
4+
5+
const batch = 3;
6+
7+
// script to remove old redis link cache entries
8+
async function main() {
9+
const domains = await prisma.domain.findMany({
10+
orderBy: {
11+
createdAt: "asc",
12+
},
13+
take: 500,
14+
skip: batch * 500,
15+
});
16+
17+
for (const domain of domains) {
18+
const res = await redis.del(domain.slug);
19+
console.log(`Deleted ${domain.slug} from redis: ${res}`);
20+
}
21+
}
22+
23+
main();

0 commit comments

Comments
 (0)