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.

Fix ProgramApplicationReminder email

Steven Tey13c462689593
diff --git a/apps/web/app/(ee)/api/cron/program-application-reminder/route.ts b/apps/web/app/(ee)/api/cron/program-application-reminder/route.ts
index bafc7665c4..f62cf6de08 100644
--- a/apps/web/app/(ee)/api/cron/program-application-reminder/route.ts
+++ b/apps/web/app/(ee)/api/cron/program-application-reminder/route.ts
@@ -18,13 +18,13 @@ export async function POST(req: Request) {
const application = await prisma.programApplication.findFirst({
where: {
id: applicationId,
- enrollment: null,
// Only send reminders for applications that were created less than 3 days ago
createdAt: {
gt: new Date(Date.now() - 3 * 24 * 60 * 60 * 1000),
},
},
include: {
+ enrollment: true,
program: {
select: {
id: true,
@@ -35,10 +35,41 @@ export async function POST(req: Request) {
},
});
- if (!application)
+ if (!application) {
return new Response(
- `Application ${applicationId} without partner not found. Skipping...`,
+ `Application ${applicationId} not found. Skipping...`,
);
+ }
+
+ if (application.enrollment) {
+ return new Response(
+ `Partner with applicationId ${application.id} has already been enrolled in program ${application.program.name}. Skipping...`,
+ );
+ }
+
+ const programEnrollment = await prisma.programEnrollment.findFirst({
+ where: {
+ programId: application.program.id,
+ partner: {
+ email: application.email,
+ },
+ },
+ });
+
+ if (programEnrollment) {
+ await prisma.programEnrollment.update({
+ where: {
+ id: programEnrollment.id,
+ },
+ data: {
+ applicationId: application.id,
+ },
+ });
+
+ return new Response(
+ `Partner with email ${application.email} has already been enrolled in program ${application.program.name}. Updated applicationId to ${application.id} and skipping...`,
+ );
+ }
await sendEmail({
subject: `Complete your application for ${application.program.name}`,
diff --git a/apps/web/scripts/wispr-flow/update-links.ts b/apps/web/scripts/wispr-flow/update-links.ts
new file mode 100644
index 0000000000..c7fe21e762
--- /dev/null
+++ b/apps/web/scripts/wispr-flow/update-links.ts
@@ -0,0 +1,41 @@
+import { prisma } from "@dub/prisma";
+import "dotenv-flow/config";
+import { linkCache } from "../../lib/api/links/cache";
+
+// update links
+async function main() {
+ const url = undefined;
+ if (!url) {
+ console.log("No url provided");
+ return;
+ }
+
+ const links = await prisma.link.findMany({
+ where: {
+ folderId: "fold_mslj7fMwqZPIFJqPQIoenL8H",
+ ios: {
+ not: url,
+ },
+ },
+ take: 100,
+ });
+
+ const updatedLinks = await prisma.link.updateMany({
+ where: {
+ id: {
+ in: links.map((link) => link.id),
+ },
+ },
+ data: {
+ ios: url,
+ },
+ });
+
+ console.log(updatedLinks);
+
+ const res = await linkCache.expireMany(links);
+
+ console.log(res);
+}
+
+main();