The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Refactor workflow execution logic to include condition handling for "SendCampaign" action and limit program enrollment retrieval to 50 records
Kiran K348500bf3c38
diff --git a/apps/web/app/(ee)/api/workflows/partner-approved/route.ts b/apps/web/app/(ee)/api/workflows/partner-approved/route.tsindex b158343290..df6c203fd9 100644--- a/apps/web/app/(ee)/api/workflows/partner-approved/route.ts+++ b/apps/web/app/(ee)/api/workflows/partner-approved/route.ts@@ -40,7 +40,7 @@ type Payload = z.infer<typeof payloadSchema>;** 4. **Trigger Draft Bounty Submission Creation**: Triggers the creation of* draft bounty submissions for the partner if they are eligible for performance bounties.- *+ ** 5. **Execute Dub Workflows**: Executes Dub workflows using the “partnerEnrolled” trigger.*/diff --git a/apps/web/lib/api/workflows/execute-send-campaign-workflow.ts b/apps/web/lib/api/workflows/execute-send-campaign-workflow.tsindex 000292473e..515d4d2367 100644--- a/apps/web/lib/api/workflows/execute-send-campaign-workflow.ts+++ b/apps/web/lib/api/workflows/execute-send-campaign-workflow.ts@@ -48,8 +48,6 @@ export const executeSendCampaignWorkflow = async ({return;}- console.log(context, buildEnrollmentWhere(condition));-let programEnrollments = await prisma.programEnrollment.findMany({where: {programId,@@ -73,6 +71,7 @@ export const executeSendCampaignWorkflow = async ({},},},+ take: 50,});if (programEnrollments.length === 0) {diff --git a/apps/web/lib/api/workflows/execute-workflows.ts b/apps/web/lib/api/workflows/execute-workflows.tsindex 38d3c02bf8..d54099af3d 100644--- a/apps/web/lib/api/workflows/execute-workflows.ts+++ b/apps/web/lib/api/workflows/execute-workflows.ts@@ -71,22 +71,28 @@ export async function executeWorkflows({// Execute each workflow for the programfor (const workflow of workflows) {- const { action } = parseWorkflowConfig(workflow);+ const { action, condition } = parseWorkflowConfig(workflow);switch (action.type) {- case WORKFLOW_ACTION_TYPES.AwardBounty:+ case WORKFLOW_ACTION_TYPES.AwardBounty: {await executeCompleteBountyWorkflow({workflow,context: workflowContext,});+break;+ }++ case WORKFLOW_ACTION_TYPES.SendCampaign: {+ if (["partnerJoined"].includes(condition.attribute)) {+ await executeSendCampaignWorkflow({+ workflow,+ context: workflowContext,+ });+ }- case WORKFLOW_ACTION_TYPES.SendCampaign:- await executeSendCampaignWorkflow({- workflow,- context: workflowContext,- });break;+ }}}}