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 scripts

Steven Tey01cd48fadcf8
diff --git a/apps/web/scripts/convert-case-sensitive.ts b/apps/web/scripts/convert-case-sensitive.ts
index f54f60ba15..0a295f42f6 100644
--- a/apps/web/scripts/convert-case-sensitive.ts
+++ b/apps/web/scripts/convert-case-sensitive.ts
@@ -7,10 +7,7 @@ import { encodeKeyIfCaseSensitive } from "../lib/api/links/case-sensitivity";
// script to convert existing links for a domain to case sensitive (encoded) setup
async function main() {
const where: Prisma.LinkWhereInput = {
- domain: "domain.com",
- createdAt: {
- lt: new Date("2025-06-30T23:59:59.999Z"),
- },
+ domain: "xxx",
NOT: {
key: {
endsWith: "=",
@@ -35,13 +32,6 @@ async function main() {
await Promise.all(
links.map(async (link) => {
- if (link.key.length > 7) {
- console.log(
- `Skipping link ${link.id} because key length is greater than 7 (already encoded)`,
- );
- return;
- }
-
const newKey = encodeKeyIfCaseSensitive({
domain: link.domain,
key: link.key,
diff --git a/apps/web/scripts/perplexity/update-commissions.ts b/apps/web/scripts/perplexity/update-commissions.ts
new file mode 100644
index 0000000000..a658c1c5f7
--- /dev/null
+++ b/apps/web/scripts/perplexity/update-commissions.ts
@@ -0,0 +1,31 @@
+import { prisma } from "@dub/prisma";
+import { Prisma } from "@dub/prisma/client";
+import "dotenv-flow/config";
+
+// update commissions for a program
+async function main() {
+ const where: Prisma.CommissionWhereInput = {
+ programId: "prog_xxx",
+ partnerId: "pn_xxx",
+ status: "processed",
+ };
+
+ const remainingCommissions = await prisma.commission.findMany({
+ where,
+ });
+ console.log(`${remainingCommissions.length} commissions to update`);
+
+ const updatedRes = await prisma.commission.updateMany({
+ where: {
+ id: {
+ in: remainingCommissions.map((c) => c.id),
+ },
+ },
+ data: {
+ earnings: 0,
+ },
+ });
+ console.log(`${updatedRes.count} commissions updated`);
+}
+
+main();