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.

reward update emails to active enrollments

Pedro Ladeira860398ca42a9
diff --git a/apps/web/app/(ee)/api/cron/rewards/process/route.ts b/apps/web/app/(ee)/api/cron/rewards/process/route.ts
index bb558cf52b..3d45341538 100644
--- a/apps/web/app/(ee)/api/cron/rewards/process/route.ts
+++ b/apps/web/app/(ee)/api/cron/rewards/process/route.ts
@@ -6,7 +6,10 @@ import {
import { isStaleRewardVersion } from "@/lib/api/rewards/reward-version";
import { withCron } from "@/lib/cron/with-cron";
import { prisma } from "@/lib/prisma";
-import { INACTIVE_ENROLLMENT_STATUSES } from "@/lib/zod/schemas/partners";
+import {
+ ACTIVE_ENROLLMENT_STATUSES,
+ INACTIVE_ENROLLMENT_STATUSES,
+} from "@/lib/zod/schemas/partners";
import { REWARD_EVENT_COLUMN_MAPPING } from "@/lib/zod/schemas/rewards";
import { Prisma } from "@prisma/client";
import { logAndRespond } from "../../utils";
@@ -113,6 +116,7 @@ export const POST = withCron(async ({ rawBody }) => {
},
select: {
id: true,
+ status: true,
partner: {
select: {
users: {
@@ -161,9 +165,9 @@ export const POST = withCron(async ({ rawBody }) => {
}
if (shouldNotify) {
- const users = programEnrollments.flatMap(({ partner }) =>
- partner.users.map(({ user }) => user),
- );
+ const users = programEnrollments
+ .filter(({ status }) => ACTIVE_ENROLLMENT_STATUSES.includes(status))
+ .flatMap(({ partner }) => partner.users.map(({ user }) => user));
await notifyPartnerRewardChange({
action: event,