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.

final changes

Steven Teye7deac91aa16
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 a6ff89a4f5..c688dfcb2b 100644
--- a/apps/web/lib/api/workflows/execute-award-bounty-action.ts
+++ b/apps/web/lib/api/workflows/execute-award-bounty-action.ts
@@ -40,11 +40,6 @@ export const executeAwardBountyAction = async ({
include: {
program: true,
groups: true,
- submissions: {
- where: {
- partnerId,
- },
- },
},
});
@@ -66,28 +61,17 @@ export const executeAwardBountyAction = async ({
const now = new Date();
- // Check bounty validity
+ // Check if bounty is active
if (
(bounty.startsAt && bounty.startsAt > now) ||
(bounty.endsAt && bounty.endsAt < now) ||
bounty.archivedAt
) {
+ console.log(`Bounty ${bounty.id} is no longer active.`);
return;
}
- const { groups, submissions } = bounty;
-
- // Check if the partner has already submitted a submission for this bounty
- if (submissions.length > 0) {
- const submission = submissions[0];
-
- if (submission.status !== "draft") {
- console.log(
- `Partner ${partnerId} has an existing submission for bounty ${bounty.id} with status ${submission.status}.`,
- );
- return;
- }
- }
+ const { groups } = bounty;
// If the bounty is part of a group, check if the partner is in the group
if (groups.length > 0) {
@@ -95,14 +79,14 @@ export const executeAwardBountyAction = async ({
if (!groupIds.includes(groupId)) {
console.log(
- `Partner ${partnerId} is not eligible for bounty ${bounty.id} because they are not in any of the assigned groups.`,
+ `Partner ${partnerId} is not eligible for bounty ${bounty.id} because they are not in any of the assigned groups. Partner's groupId: ${groupId}. Assigned groupIds: ${groupIds.join(", ")}.`,
);
return;
}
}
console.log(
- `Running the workflow ${bounty.workflowId} for bounty ${bounty.id}.`,
+ `Partner is eligible for bounty ${bounty.id}, executing workflow ${bounty.workflowId}...`,
);
const finalContext: Partial<
@@ -122,7 +106,7 @@ export const executeAwardBountyAction = async ({
}),
};
- const count = finalContext[condition.attribute] ?? 0;
+ const performanceCount = finalContext[condition.attribute] ?? 0;
// Create or update the submission
const bountySubmission = await prisma.bountySubmission.upsert({
@@ -138,11 +122,11 @@ export const executeAwardBountyAction = async ({
partnerId,
bountyId: bounty.id,
status: "draft",
- performanceCount: count,
+ performanceCount,
},
update: {
performanceCount: {
- increment: count,
+ increment: performanceCount,
},
},
});
diff --git a/packages/prisma/schema/bounty.prisma b/packages/prisma/schema/bounty.prisma
index 3680b5973c..5e7a047eed 100644
--- a/packages/prisma/schema/bounty.prisma
+++ b/packages/prisma/schema/bounty.prisma
@@ -34,7 +34,7 @@ model Bounty {
endsAt DateTime?
rewardAmount Int?
rewardDescription String?
- performanceScope BountyPerformanceScope? @default(new)
+ performanceScope BountyPerformanceScope?
submissionRequirements Json?
archivedAt DateTime?
createdAt DateTime @default(now())