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.

performance based bounty updates

Kiran K1dff28af74f9
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 587122be83..e349ec2956 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
@@ -1,8 +1,9 @@
-import { getBountyOrThrow } from "@/lib/api/bounties/get-bounty-or-throw";
+import { DubApiError } from "@/lib/api/errors";
import { getDefaultProgramIdOrThrow } from "@/lib/api/programs/get-default-program-id-or-throw";
import { withWorkspace } from "@/lib/auth";
import { BountySubmissionSchema } from "@/lib/zod/schemas/bounties";
import { prisma } from "@dub/prisma";
+import { Bounty, BountyGroup, BountyType } from "@dub/prisma/client";
import { NextResponse } from "next/server";
import { z } from "zod";
@@ -14,14 +15,35 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
const { bountyId } = params;
const programId = getDefaultProgramIdOrThrow(workspace);
- await getBountyOrThrow({
- bountyId,
- programId,
+ const bounty = await prisma.bounty.findUniqueOrThrow({
+ where: {
+ id: bountyId,
+ },
+ include: {
+ groups: true,
+ },
});
+ if (bounty.programId !== programId) {
+ throw new DubApiError({
+ code: "not_found",
+ message: `Bounty ${bountyId} not found.`,
+ });
+ }
+
+ const results =
+ bounty.type === BountyType.submission
+ ? await getSubmissions(bounty)
+ : await getActivePartners(bounty);
+
+ return NextResponse.json(z.array(BountySubmissionSchema).parse(results));
+});
+
+// Get the submissions for a bounty of the type `submission`
+async function getSubmissions(bounty: Pick<Bounty, "id">) {
const submissions = await prisma.bountySubmission.findMany({
where: {
- bountyId,
+ bountyId: bounty.id,
},
include: {
user: true,
@@ -39,13 +61,81 @@ export const GET = withWorkspace(async ({ workspace, params }) => {
const results = submissions.map((submission) => {
return {
- ...submission,
partner: {
...submission.programEnrollment?.partner,
...submission.programEnrollment,
},
+ submission,
+ commission: submission.commission,
+ user: submission.user,
};
});
- return NextResponse.json(z.array(BountySubmissionSchema).parse(results));
-});
+ return results;
+}
+
+// Get active partners regardless of progress for `performance` bounties
+async function getActivePartners(bounty: Bounty & { groups: BountyGroup[] }) {
+ // TODO:
+ // Sort the list by the performance attribute
+
+
+ const programEnrollments = await prisma.programEnrollment.findMany({
+ where: {
+ programId: bounty.programId,
+ ...(bounty.groups.length > 0
+ ? {
+ groupId: {
+ in: bounty.groups.map(({ groupId }) => groupId),
+ },
+ }
+ : {}),
+ status: {
+ in: ["approved", "invited"],
+ },
+ },
+ include: {
+ links: true,
+ partner: true,
+ bountySubmissions: {
+ where: {
+ bountyId: bounty.id,
+ },
+ include: {
+ user: true,
+ commission: true,
+ },
+ },
+ },
+ });
+
+ const results = programEnrollments.map(
+ ({ links, partner, bountySubmissions, ...programEnrollment }) => {
+ const { leads, conversions, saleAmount } = links?.reduce(
+ (acc, link) => {
+ return {
+ leads: acc.leads + link.leads,
+ conversions: acc.conversions + link.conversions,
+ saleAmount: acc.saleAmount + link.saleAmount,
+ };
+ },
+ { leads: 0, conversions: 0, saleAmount: 0 },
+ );
+
+ return {
+ partner: {
+ ...partner,
+ ...programEnrollment,
+ leads,
+ conversions,
+ saleAmount,
+ },
+ submission: bountySubmissions[0] ?? null,
+ commission: bountySubmissions[0]?.commission ?? null,
+ user: bountySubmissions[0]?.user ?? null,
+ };
+ },
+ );
+
+ return results;
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
index 8150a88789..ce6290db4a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
@@ -22,11 +22,9 @@ type BountySubmissionDetailsSheetProps = {
};
function BountySubmissionDetailsSheetContent({
- submission,
+ submission: { submission, partner, commission, user },
setIsOpen,
}: BountySubmissionDetailsSheetProps) {
- console.log(submission);
-
const { bounty } = useBounty();
const { id: workspaceId, slug: workspaceSlug } = useWorkspace();
@@ -55,7 +53,7 @@ function BountySubmissionDetailsSheetContent({
description: "Are you sure you want to approve this bounty submission?",
confirmText: "Approve",
onConfirm: async () => {
- if (!workspaceId || !submission.id) {
+ if (!workspaceId || !submission?.id) {
return;
}
@@ -66,6 +64,10 @@ function BountySubmissionDetailsSheetContent({
},
});
+ if (!submission || !partner || !commission) {
+ return null;
+ }
+
return (
<div className="flex h-full flex-col">
<div className="sticky top-0 z-10 border-b border-neutral-200 bg-white">
@@ -85,12 +87,9 @@ function BountySubmissionDetailsSheetContent({
<div className="flex grow flex-col">
<div className="border-b border-neutral-200 bg-neutral-50 p-6">
- <PartnerInfoSection
- partner={submission.partner}
- showPartnerStatus={false}
- >
+ <PartnerInfoSection partner={partner} showPartnerStatus={false}>
<ButtonLink
- href={`/${workspaceSlug}/program/partners?partnerId=${submission.partner.id}`}
+ href={`/${workspaceSlug}/program/partners?partnerId=${partner.id}`}
variant="secondary"
className="h-8 w-fit px-3 py-2 text-sm font-medium"
target="_blank"
@@ -126,8 +125,8 @@ function BountySubmissionDetailsSheetContent({
Reward
</span>
<span className="text-sm font-medium text-neutral-800">
- {submission.commission?.earnings
- ? currencyFormatter(submission.commission.earnings, {
+ {commission?.earnings
+ ? currencyFormatter(commission.earnings, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
index c98753ad81..af8b81fd7a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -1,8 +1,11 @@
"use client";
+import { isCurrencyAttribute } from "@/lib/api/workflows/utils";
+import useBounty from "@/lib/swr/use-bounty";
import useGroups from "@/lib/swr/use-groups";
import useWorkspace from "@/lib/swr/use-workspace";
import { BountySubmissionProps } from "@/lib/types";
+import { WORKFLOW_ATTRIBUTE_LABELS } from "@/lib/zod/schemas/workflows";
import { GroupColorCircle } from "@/ui/partners/groups/group-color-circle";
import { PartnerRowItem } from "@/ui/partners/partner-row-item";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
@@ -15,9 +18,16 @@ import {
useTable,
} from "@dub/ui";
import { User } from "@dub/ui/icons";
-import { fetcher, formatDate } from "@dub/utils";
+import {
+ capitalize,
+ currencyFormatter,
+ fetcher,
+ formatDate,
+ nFormatter,
+} from "@dub/utils";
+import { Row } from "@tanstack/react-table";
import { useParams } from "next/navigation";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import useSWR from "swr";
import { BountySubmissionDetailsSheet } from "./bounty-submission-details-sheet";
@@ -37,6 +47,7 @@ export const BOUNTY_SUBMISSION_STATUS_BADGES = {
} as const;
export function BountySubmissionsTable() {
+ const { bounty, isLoading: isBountyLoading } = useBounty();
const { groups } = useGroups();
const { id: workspaceId } = useWorkspace();
const { bountyId } = useParams<{ bountyId: string }>();
@@ -76,13 +87,36 @@ export function BountySubmissionsTable() {
setDetailsSheetState({ open: false, submission: null });
}
- const submission = submissions?.find((s) => s.id === submissionId);
+ const submission = submissions?.find(
+ (s) => s.submission?.id === submissionId,
+ );
- if (submission) {
+ if (submission?.submission) {
setDetailsSheetState({ open: true, submission });
}
}, [searchParams, submissions]);
+ const columns = useMemo(() => {
+ const columns = ["partner", "group", "createdAt"];
+
+ if (!bounty) {
+ return columns;
+ }
+
+ if (bounty.type === "submission") {
+ columns.push(...["status", "reviewedAt"]);
+ } else if (bounty.type === "performance") {
+ columns.push(...["performanceMetrics"]);
+ }
+
+ return columns;
+ }, [bounty]);
+
+ const performanceCondition = bounty?.performanceCondition;
+ const metricLabel = performanceCondition?.attribute
+ ? WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute]
+ : "Progress";
+
const { table, ...tableProps } = useTable({
data: submissions || [],
columns: [
@@ -119,50 +153,119 @@ export function BountySubmissionsTable() {
);
},
},
- {
- id: "status",
- header: "Status",
- cell: ({ row }) => {
- const badge = BOUNTY_SUBMISSION_STATUS_BADGES[row.original.status];
-
- return badge ? (
- <StatusBadge icon={null} variant={badge.variant}>
- {badge.label}
- </StatusBadge>
- ) : (
- "-"
- );
- },
- },
+
+ ...(columns.includes("status")
+ ? [
+ {
+ id: "status",
+ header: "Status",
+ cell: ({ row }) => {
+ const badge = row.original.submission
+ ? BOUNTY_SUBMISSION_STATUS_BADGES[
+ row.original.submission.status
+ ]
+ : null;
+
+ return badge ? (
+ <StatusBadge icon={null} variant={badge.variant}>
+ {badge.label}
+ </StatusBadge>
+ ) : (
+ "-"
+ );
+ },
+ },
+ ]
+ : []),
+
{
id: "createdAt",
- header: "Submitted",
- accessorFn: (d) => formatDate(d.createdAt, { month: "short" }),
- },
- {
- id: "reviewedAt",
- header: "Reviewed",
- cell: ({ row }) => {
- return row.original.reviewedAt ? (
- <UserRowItem
- user={row.original.user!}
- date={row.original.reviewedAt}
- label={
- row.original.status === "approved"
- ? "Approved at"
- : "Rejected at"
- }
- />
- ) : (
- "-"
- );
- },
+ header: bounty?.type === "submission" ? "Submitted" : "Completed",
+ accessorFn: (d) =>
+ d.submission
+ ? formatDate(d.submission.createdAt, { month: "short" })
+ : "-",
},
+
+ // TODO: fix this
+ ...(columns.includes("performanceMetrics")
+ ? [
+ {
+ id: "performanceMetrics",
+ header: capitalize(metricLabel)!,
+ cell: ({ row }: { row: Row<BountySubmissionProps> }) => {
+ if (!performanceCondition) {
+ return "-";
+ }
+
+ const attribute = performanceCondition.attribute;
+ const target = performanceCondition.value;
+ let value: number | undefined = undefined;
+
+ if (attribute === "totalLeads") {
+ value = row.original.partner.leads;
+ } else if (attribute === "totalConversions") {
+ value = row.original.partner.conversions;
+ } else if (attribute === "totalSaleAmount") {
+ value = row.original.partner.saleAmount;
+ } else if (attribute === "totalCommission") {
+ value = row.original.partner.totalCommissions;
+ }
+
+ if (value === undefined) {
+ return "-";
+ }
+
+ const formattedValue = isCurrencyAttribute(attribute)
+ ? currencyFormatter(value / 100)
+ : nFormatter(value);
+
+ const formattedTarget = isCurrencyAttribute(attribute)
+ ? currencyFormatter(target / 100)
+ : nFormatter(target);
+
+ return (
+ <span className="text-sm font-medium leading-5 text-neutral-600">
+ {formattedValue} / {formattedTarget}
+ </span>
+ );
+ },
+ },
+ ]
+ : []),
+
+ ...(columns.includes("reviewedAt")
+ ? [
+ {
+ id: "reviewedAt",
+ header: "Reviewed",
+ cell: ({ row }) => {
+ return row.original.submission?.reviewedAt ? (
+ <UserRowItem
+ user={row.original.user!}
+ date={row.original.submission?.reviewedAt}
+ label={
+ row.original.submission?.status === "approved"
+ ? "Approved at"
+ : "Rejected at"
+ }
+ />
+ ) : (
+ "-"
+ );
+ },
+ },
+ ]
+ : []),
],
onRowClick: (row) => {
+ if (!row.original.submission) {
+ return;
+ }
+
queryParams({
set: {
- submissionId: row.original.id,
+ submissionId: row.original.submission.id,
},
scroll: false,
});
@@ -185,7 +288,7 @@ export function BountySubmissionsTable() {
tdClassName: "border-l-0",
resourceName: (p) => `submission${p ? "s" : ""}`,
rowCount: submissions?.length || 0,
- loading: isLoading,
+ loading: isLoading || isBountyLoading,
error: error ? "Failed to load bounty submissions" : undefined,
});
diff --git a/apps/web/lib/api/bounties/get-bounties.ts b/apps/web/lib/api/bounties/get-bounties.ts
index e71c9781d1..5decacaf29 100644
--- a/apps/web/lib/api/bounties/get-bounties.ts
+++ b/apps/web/lib/api/bounties/get-bounties.ts
@@ -31,6 +31,7 @@ export async function getBounties(filters: BountyFilters) {
b.endsAt,
b.rewardAmount,
b.submissionRequirements,
+ wf.triggerConditions,
${
includeExpandedFields
? Prisma.sql`
@@ -60,6 +61,7 @@ export async function getBounties(filters: BountyFilters) {
`
: Prisma.sql``
}
+ LEFT JOIN Workflow wf ON wf.id = b.workflowId
WHERE b.programId = ${programId}
GROUP BY b.id, b.name, b.description, b.type, b.startsAt, b.endsAt, b.rewardAmount, b.submissionRequirements
ORDER BY ${Prisma.raw(sortColumnsMap[sortBy])} ${Prisma.raw(sortOrder)}
@@ -70,5 +72,7 @@ export async function getBounties(filters: BountyFilters) {
...bounty,
partnersCount: Number(bounty.partnersCount),
groups: bounty.groups.filter((group) => group !== null),
+ performanceCondition:
+ bounty.triggerConditions?.length > 0 ? bounty.triggerConditions[0] : null,
}));
}
diff --git a/apps/web/lib/api/bounties/get-bounty-or-throw.ts b/apps/web/lib/api/bounties/get-bounty-or-throw.ts
index c1fb9c01dc..fbcb171545 100644
--- a/apps/web/lib/api/bounties/get-bounty-or-throw.ts
+++ b/apps/web/lib/api/bounties/get-bounty-or-throw.ts
@@ -20,6 +20,8 @@ export const getBountyOrThrow = async ({
b.startsAt,
b.endsAt,
b.rewardAmount,
+ b.submissionRequirements,
+ wf.triggerConditions,
${
includeExpandedFields
? Prisma.sql`
@@ -49,6 +51,7 @@ export const getBountyOrThrow = async ({
`
: Prisma.sql``
}
+ LEFT JOIN Workflow wf ON wf.id = b.workflowId
WHERE b.programId = ${programId}
AND b.id = ${bountyId}
GROUP BY b.id
@@ -62,9 +65,13 @@ export const getBountyOrThrow = async ({
});
}
+ const bounty = bounties[0];
+
return {
- ...bounties[0],
- partnersCount: Number(bounties[0].partnersCount),
- groups: bounties[0].groups.filter((group) => group !== null),
+ ...bounty,
+ performanceCondition:
+ bounty.triggerConditions?.length > 0 ? bounty.triggerConditions[0] : null,
+ partnersCount: Number(bounty.partnersCount),
+ groups: bounty.groups.filter((group) => group !== null),
};
};
diff --git a/apps/web/lib/api/workflows/execute-workflows.ts b/apps/web/lib/api/workflows/execute-workflows.ts
index d3defd356a..6eafc8e0e8 100644
--- a/apps/web/lib/api/workflows/execute-workflows.ts
+++ b/apps/web/lib/api/workflows/execute-workflows.ts
@@ -160,10 +160,5 @@ async function executeWorkflowAction({
context,
});
break;
- case "sendEmail":
- case "moveToGroup":
- case "triggerWebhook":
- console.log(`Not implemented ${action.type}`);
- break;
}
}
diff --git a/apps/web/lib/zod/schemas/bounties.ts b/apps/web/lib/zod/schemas/bounties.ts
index eda4549c1f..08fcbfa8da 100644
--- a/apps/web/lib/zod/schemas/bounties.ts
+++ b/apps/web/lib/zod/schemas/bounties.ts
@@ -51,7 +51,8 @@ export const BountySchema = z.object({
startsAt: z.date(),
endsAt: z.date().nullable(),
rewardAmount: z.number(),
- submissionRequirements: bountySubmissionRequirementsSchema.nullish(),
+ submissionRequirements: bountySubmissionRequirementsSchema.nullable(),
+ performanceCondition: workflowConditionSchema.nullable().default(null),
});
export const BountySchemaExtended = BountySchema.extend({
@@ -72,16 +73,20 @@ export const BountySubmissionFileSchema = z.object({
});
export const BountySubmissionSchema = z.object({
- id: z.string(),
- description: z.string().nullable(),
- urls: z.array(z.string()).nullable(),
- files: z.array(BountySubmissionFileSchema).nullable(),
- status: z.nativeEnum(BountySubmissionStatus),
- createdAt: z.date(),
- updatedAt: z.date(),
- reviewedAt: z.date().nullable(),
- rejectionReason: z.string().nullable(),
- rejectionNote: z.string().nullable(),
+ submission: z
+ .object({
+ id: z.string(),
+ description: z.string().nullable(),
+ urls: z.array(z.string()).nullable(),
+ files: z.array(BountySubmissionFileSchema).nullable(),
+ status: z.nativeEnum(BountySubmissionStatus),
+ createdAt: z.date(),
+ updatedAt: z.date(),
+ reviewedAt: z.date().nullable(),
+ rejectionReason: z.string().nullable(),
+ rejectionNote: z.string().nullable(),
+ })
+ .nullable(),
partner: EnrolledPartnerSchema.pick({
id: true,
name: true,
@@ -93,6 +98,10 @@ export const BountySubmissionSchema = z.object({
status: true,
bannedAt: true,
bannedReason: true,
+ leads: true,
+ conversions: true,
+ saleAmount: true,
+ totalCommissions: true,
}),
commission: CommissionSchema.pick({
id: true,
diff --git a/apps/web/lib/zod/schemas/workflows.ts b/apps/web/lib/zod/schemas/workflows.ts
index 5ed02d7b05..d3c820bb5f 100644
--- a/apps/web/lib/zod/schemas/workflows.ts
+++ b/apps/web/lib/zod/schemas/workflows.ts
@@ -50,10 +50,7 @@ export const WORKFLOW_COMPARISON_OPERATOR_LABELS: Record<
} as const;
export enum WORKFLOW_ACTION_TYPES {
- SendEmail = "sendEmail",
- MoveToGroup = "moveToGroup",
AwardBounty = "awardBounty",
- TriggerWebhook = "triggerWebhook",
}
export const WORKFLOW_LOGICAL_OPERATORS = ["AND"] as const;
@@ -73,33 +70,12 @@ export const workflowConditionsSchema = z.object({
// Individual action
export const workflowActionSchema = z.discriminatedUnion("type", [
- z.object({
- type: z.literal("sendEmail"),
- data: z.object({
- emailId: z.string(),
- }),
- }),
-
- z.object({
- type: z.literal("moveToGroup"),
- data: z.object({
- groupId: z.string(),
- }),
- }),
-
z.object({
type: z.literal("awardBounty"),
data: z.object({
bountyId: z.string(),
}),
}),
-
- z.object({
- type: z.literal("triggerWebhook"),
- data: z.object({
- webhookId: z.string(),
- }),
- }),
]);
// Array of actions (Only supports one action for now)
diff --git a/apps/web/scripts/bounty.ts b/apps/web/scripts/bounty.ts
index 55b5f558c7..c488a3cc0d 100644
--- a/apps/web/scripts/bounty.ts
+++ b/apps/web/scripts/bounty.ts
@@ -1,28 +1,17 @@
+import { createId } from "@/lib/api/create-id";
import { prisma } from "@dub/prisma";
import "dotenv-flow/config";
// TODO:
// Remove this
async function main() {
- const programId = "prog_1K2J9DRWPPJ2F1RX53N92TSGA";
- const bountyId = "bounty_1K33NYERM0XZS1HK7C82C77K0";
-
- const programEnrollments = await prisma.programEnrollment.findMany({
- where: {
- programId,
+ await prisma.bountySubmission.create({
+ data: {
+ id: createId({ prefix: "bnty_sub_" }),
+ programId: "prog_1K2J9DRWPPJ2F1RX53N92TSGA",
+ partnerId: "pn_1K33CAFZV9XKMBJFW23V1VEXP",
+ bountyId: "bnty_1K38BKWCB1CZYTCXAXYCDYKXQ",
},
- take: 5
- });
-
- // Create a submission for each partner
- const submissions = programEnrollments.map(({ partnerId }) => ({
- programId,
- partnerId,
- bountyId,
- }));
-
- await prisma.bountySubmission.createMany({
- data: submissions,
});
}
diff --git a/apps/web/ui/partners/reject-bounty-submission-modal.tsx b/apps/web/ui/partners/reject-bounty-submission-modal.tsx
index e4c23a233f..1603a794da 100644
--- a/apps/web/ui/partners/reject-bounty-submission-modal.tsx
+++ b/apps/web/ui/partners/reject-bounty-submission-modal.tsx
@@ -18,7 +18,7 @@ import { z } from "zod";
type FormData = z.infer<typeof rejectBountySubmissionSchema>;
interface RejectBountySubmissionModalProps {
- submission: Pick<BountySubmissionProps, "id">;
+ submission: BountySubmissionProps["submission"];
showModal: boolean;
setShowModal: (showModal: boolean) => void;
}
@@ -144,7 +144,7 @@ const RejectBountySubmissionModal = ({
className="h-9 w-fit"
loading={isPending}
onClick={async () => {
- if (!workspace.id || !submission.id) {
+ if (!workspace.id || !submission?.id) {
return;
}
@@ -164,7 +164,7 @@ const RejectBountySubmissionModal = ({
};
export function useRejectBountySubmissionModal(
- submission: Pick<BountySubmissionProps, "id">,
+ submission: BountySubmissionProps["submission"],
onReject?: () => void,
) {
const [showRejectModal, setShowRejectModal] = useState(false);
diff --git a/packages/prisma/schema/program.prisma b/packages/prisma/schema/program.prisma
index ec54dec771..c58e42b45d 100644
--- a/packages/prisma/schema/program.prisma
+++ b/packages/prisma/schema/program.prisma
@@ -96,16 +96,16 @@ model ProgramEnrollment {
bannedAt DateTime?
bannedReason PartnerBannedReason?
- partner Partner @relation(fields: [partnerId], references: [id], onUpdate: Cascade, onDelete: Cascade)
- program Program @relation(fields: [programId], references: [id], onUpdate: Cascade, onDelete: Cascade)
- links Link[]
- partnerGroup PartnerGroup? @relation(fields: [groupId], references: [id])
- application ProgramApplication? @relation(fields: [applicationId], references: [id])
- clickReward Reward? @relation("ClickRewardEnrollments", fields: [clickRewardId], references: [id])
- leadReward Reward? @relation("LeadRewardEnrollments", fields: [leadRewardId], references: [id])
- saleReward Reward? @relation("SaleRewardEnrollments", fields: [saleRewardId], references: [id])
- discount Discount? @relation(fields: [discountId], references: [id])
- bountySubmission BountySubmission[]
+ partner Partner @relation(fields: [partnerId], references: [id], onUpdate: Cascade, onDelete: Cascade)
+ program Program @relation(fields: [programId], references: [id], onUpdate: Cascade, onDelete: Cascade)
+ links Link[]
+ partnerGroup PartnerGroup? @relation(fields: [groupId], references: [id])
+ application ProgramApplication? @relation(fields: [applicationId], references: [id])
+ clickReward Reward? @relation("ClickRewardEnrollments", fields: [clickRewardId], references: [id])
+ leadReward Reward? @relation("LeadRewardEnrollments", fields: [leadRewardId], references: [id])
+ saleReward Reward? @relation("SaleRewardEnrollments", fields: [saleRewardId], references: [id])
+ discount Discount? @relation(fields: [discountId], references: [id])
+ bountySubmissions BountySubmission[]
@@unique([partnerId, programId])
@@unique([tenantId, programId])