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.

Improve workflow condition evaluation and fix status mapping

Kiran Kff1926f17c61
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
index 762b870343..7dc2b51cbd 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
@@ -49,6 +49,7 @@ export const GET = withWorkspace(
groupIds: bounty.groups.map(({ groupId }) => groupId),
});
+
return NextResponse.json(
z.array(BountySubmissionExtendedSchema).parse(results),
);
diff --git a/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts b/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts
index cb56eee796..6429c6a37f 100644
--- a/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts
+++ b/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts
@@ -82,7 +82,7 @@ export async function getPartnersWithBountySubmission({
description: row.description,
urls: row.urls,
files: row.files,
- status: row.status,
+ status: row.bountySubmissionStatus,
createdAt: row.bountySubmissionCreatedAt,
updatedAt: row.bountySubmissionUpdatedAt,
reviewedAt: row.reviewedAt,
diff --git a/apps/web/lib/api/workflows/execute-award-bounty-action.ts b/apps/web/lib/api/workflows/execute-award-bounty-action.ts
index 9240e36a6c..ca21d48634 100644
--- a/apps/web/lib/api/workflows/execute-award-bounty-action.ts
+++ b/apps/web/lib/api/workflows/execute-award-bounty-action.ts
@@ -139,11 +139,7 @@ export const executeAwardBountyAction = async ({
const shouldExecute = evaluateWorkflowCondition({
condition,
context: {
- totalLeads: 0,
- totalConversions: 0,
- totalSaleAmount: 0,
- totalCommissions: 0,
- [condition.attribute]: bountySubmission.count, // override the attribute
+ [condition.attribute]: bountySubmission.count,
},
});
diff --git a/apps/web/lib/api/workflows/execute-workflows.ts b/apps/web/lib/api/workflows/execute-workflows.ts
index 70c50abbd5..262f4ddf37 100644
--- a/apps/web/lib/api/workflows/execute-workflows.ts
+++ b/apps/web/lib/api/workflows/execute-workflows.ts
@@ -118,9 +118,12 @@ export function evaluateWorkflowCondition({
context,
}: {
condition: WorkflowCondition;
- context: Record<WorkflowConditionAttribute, number>;
+ context: Partial<Record<WorkflowConditionAttribute, number | null>>;
}) {
- console.log("Evaluating workflow condition", condition, context);
+ console.log("Evaluating the workflow condition:", {
+ condition,
+ context
+ });
const operatorFn = OPERATOR_FUNCTIONS[condition.operator];
@@ -130,5 +133,12 @@ export function evaluateWorkflowCondition({
);
}
- return operatorFn(context[condition.attribute], condition.value);
+ const attributeValue = context[condition.attribute];
+
+ // If the attribute is not provided in context, return false
+ if (!attributeValue) {
+ return false;
+ }
+
+ return operatorFn(attributeValue, condition.value);
}