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 programs without published application forms from marketplace

Tim Wilson994016765a4f
diff --git a/apps/web/app/(ee)/api/network/programs/[programSlug]/route.ts b/apps/web/app/(ee)/api/network/programs/[programSlug]/route.ts
index 07735fb7e9..f0e0289097 100644
--- a/apps/web/app/(ee)/api/network/programs/[programSlug]/route.ts
+++ b/apps/web/app/(ee)/api/network/programs/[programSlug]/route.ts
@@ -23,6 +23,14 @@ export const GET = withPartnerProfile(async ({ partner, params }) => {
addedToMarketplaceAt: {
not: null,
},
+ groups: {
+ some: {
+ slug: DEFAULT_PARTNER_GROUP.slug,
+ applicationFormPublishedAt: {
+ not: null,
+ },
+ },
+ },
},
include: {
groups: {
diff --git a/apps/web/app/(ee)/api/network/programs/count/route.ts b/apps/web/app/(ee)/api/network/programs/count/route.ts
index 16e1c878b6..c24c2a7d30 100644
--- a/apps/web/app/(ee)/api/network/programs/count/route.ts
+++ b/apps/web/app/(ee)/api/network/programs/count/route.ts
@@ -28,6 +28,22 @@ export const GET = withPartnerProfile(async ({ partner, searchParams }) => {
const searchSql = search ? Prisma.sql`CONCAT('%', ${search}, '%')` : null;
const commonWhereSql = Prisma.sql`
p.addedToMarketplaceAt IS NOT NULL
+ AND EXISTS (
+ SELECT 1 FROM PartnerGroup pg
+ WHERE
+ pg.programId = p.id
+ AND pg.slug = ${DEFAULT_PARTNER_GROUP.slug}
+ AND pg.applicationFormPublishedAt IS NOT NULL
+ ${
+ rewardType && groupBy !== "rewardType"
+ ? Prisma.sql`
+ AND ${Prisma.join(
+ rewardType.map((type) => rewardTypeMap[type]),
+ " AND ",
+ )}`
+ : Prisma.sql``
+ }
+ )
${
category && groupBy !== "category"
? Prisma.sql`
@@ -37,21 +53,6 @@ export const GET = withPartnerProfile(async ({ partner, searchParams }) => {
)`
: Prisma.sql``
}
- ${
- rewardType && groupBy !== "rewardType"
- ? Prisma.sql`
- AND EXISTS (
- SELECT 1 FROM PartnerGroup pg
- WHERE
- pg.programId = p.id
- AND pg.slug = ${DEFAULT_PARTNER_GROUP.slug}
- AND ${Prisma.join(
- rewardType.map((type) => rewardTypeMap[type]),
- " AND ",
- )}
- )`
- : Prisma.sql``
- }
${
status !== undefined && groupBy !== "status"
? Prisma.sql`
diff --git a/apps/web/app/(ee)/api/network/programs/route.ts b/apps/web/app/(ee)/api/network/programs/route.ts
index ffcd09bcbc..bcf7dbb4dc 100644
--- a/apps/web/app/(ee)/api/network/programs/route.ts
+++ b/apps/web/app/(ee)/api/network/programs/route.ts
@@ -32,9 +32,19 @@ export const GET = withPartnerProfile(async ({ partner, searchParams }) => {
const programs = await prisma.program.findMany({
where: {
+ // Added to marketplace
addedToMarketplaceAt: {
not: null,
},
+ // Has a published default application form
+ groups: {
+ some: {
+ slug: DEFAULT_PARTNER_GROUP.slug,
+ applicationFormPublishedAt: {
+ not: null,
+ },
+ },
+ },
...(featured && {
featuredOnMarketplaceAt: {
not: null,