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.

Hide tag-scoped bounties from group landers (#4485)

Pedro Ladeira94cb73a2800e
diff --git a/apps/web/lib/bounty/api/get-group-bounty-summaries.ts b/apps/web/lib/bounty/api/get-group-bounty-summaries.ts
index 4e29bdb625..a3c173cd81 100644
--- a/apps/web/lib/bounty/api/get-group-bounty-summaries.ts
+++ b/apps/web/lib/bounty/api/get-group-bounty-summaries.ts
@@ -9,6 +9,7 @@ type BountyEligibilityCandidate = {
endsAt: Date | null;
archivedAt: Date | null;
groups: { groupId: string }[];
+ partnerTags: { partnerTagId: string }[];
};
export function filterActiveGroupBounties(
@@ -34,6 +35,10 @@ export function filterActiveGroupBounties(
return false;
}
+ if (bounty.partnerTags.length > 0) {
+ return false;
+ }
+
return (
bounty.groups.length === 0 ||
bounty.groups.some((group) => group.groupId === groupId)
@@ -66,6 +71,11 @@ export async function getGroupBountySummaries({
groupId: true,
},
},
+ partnerTags: {
+ select: {
+ partnerTagId: true,
+ },
+ },
},
orderBy: {
startsAt: "asc",
diff --git a/apps/web/tests/misc/filter-active-group-bounties.test.ts b/apps/web/tests/misc/filter-active-group-bounties.test.ts
index 2bd238df98..3366f0cf6e 100644
--- a/apps/web/tests/misc/filter-active-group-bounties.test.ts
+++ b/apps/web/tests/misc/filter-active-group-bounties.test.ts
@@ -16,6 +16,7 @@ function makeCandidate(
endsAt: Date | null;
archivedAt: Date | null;
groups: { groupId: string }[];
+ partnerTags: { partnerTagId: string }[];
}> = {},
) {
return {
@@ -26,6 +27,7 @@ function makeCandidate(
endsAt: null,
archivedAt: null,
groups: [],
+ partnerTags: [],
...overrides,
};
}
@@ -151,4 +153,51 @@ describe("filterActiveGroupBounties", () => {
});
expect(result.map((b) => b.id)).toEqual(["bnty_4", "bnty_5"]);
});
+
+ it("excludes tag-scoped bounties with no groups", () => {
+ const bounty = makeCandidate({
+ partnerTags: [{ partnerTagId: "ptag_1" }],
+ });
+ const result = filterActiveGroupBounties([bounty], {
+ groupId: GROUP_ID,
+ now: NOW,
+ });
+ expect(result).toHaveLength(0);
+ });
+
+ it("excludes tag-scoped bounties even when groups match", () => {
+ const bounty = makeCandidate({
+ groups: [{ groupId: GROUP_ID }],
+ partnerTags: [{ partnerTagId: "ptag_1" }],
+ });
+ const result = filterActiveGroupBounties([bounty], {
+ groupId: GROUP_ID,
+ now: NOW,
+ });
+ expect(result).toHaveLength(0);
+ });
+
+ it("includes group-scoped bounties with empty partnerTags", () => {
+ const bounty = makeCandidate({
+ groups: [{ groupId: GROUP_ID }],
+ partnerTags: [],
+ });
+ const result = filterActiveGroupBounties([bounty], {
+ groupId: GROUP_ID,
+ now: NOW,
+ });
+ expect(result).toHaveLength(1);
+ });
+
+ it("includes global bounties with empty partnerTags", () => {
+ const bounty = makeCandidate({
+ groups: [],
+ partnerTags: [],
+ });
+ const result = filterActiveGroupBounties([bounty], {
+ groupId: GROUP_ID,
+ now: NOW,
+ });
+ expect(result).toHaveLength(1);
+ });
});