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.

Update partner ranking logic to include all partners

Kiran K2465375f7e3a
diff --git a/apps/web/lib/api/network/partner-ranking.ts b/apps/web/lib/api/network/partner-ranking.ts
index 3ae2b09ce4..8703376735 100644
--- a/apps/web/lib/api/network/partner-ranking.ts
+++ b/apps/web/lib/api/network/partner-ranking.ts
@@ -45,10 +45,9 @@ export async function calculatePartnerRanking({
pageSize,
status = "discover",
}: PartnerRankingParams) {
- // Build WHERE clause conditions
const conditions: Prisma.Sql[] = [
- Prisma.sql`p.discoverableAt IS NOT NULL`,
- Prisma.sql`dp.ignoredAt IS NULL`,
+ // Removed discoverableAt requirement to show all partners
+ Prisma.sql`(dp.ignoredAt IS NULL OR dp.id IS NULL)`, // Allow partners not yet discovered
Prisma.sql`COALESCE(pe.conversionRate, 0) < 1`,
];
@@ -75,7 +74,7 @@ export async function calculatePartnerRanking({
if (starred === true) {
conditions.push(Prisma.sql`dp.starredAt IS NOT NULL`);
} else if (starred === false) {
- conditions.push(Prisma.sql`dp.starredAt IS NULL`);
+ conditions.push(Prisma.sql`(dp.starredAt IS NULL OR dp.id IS NULL)`);
}
const whereClause = Prisma.join(conditions, " AND ");
@@ -243,7 +242,6 @@ export async function calculatePartnerRanking({
SELECT
pe4.partnerId,
MAX(pe4.lastConversionAt) as lastConversionAt,
- -- Calculate weighted average conversion rate
SUM(COALESCE(pe4.conversionRate, 0) * ps3.similarityScore) / NULLIF(SUM(ps3.similarityScore), 0) as avgConversionRate
FROM ProgramSimilarity ps3
JOIN ProgramEnrollment pe4