The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fix partner count fallback for referral filters
Rafida83431fd208
diff --git a/apps/web/lib/api/partners/get-partners-count.ts b/apps/web/lib/api/partners/get-partners-count.tsindex cc6304cb31..c93221e3c5 100644--- a/apps/web/lib/api/partners/get-partners-count.ts+++ b/apps/web/lib/api/partners/get-partners-count.ts@@ -64,6 +64,7 @@ export async function getPartnersCount<T>(groupId,partnerTagId,tenantId,+ referredByPartnerId,partnerTagIdOperator = "IN",groupIdOperator = "IN",countryOperator = "IN",@@ -265,9 +266,14 @@ export async function getPartnersCount<T>(// thousand. Ask the provider for the real total instead, but only when it can// see every filter that applies: `partnerIds`, `tenantId`, and the metric// ranges are database-only, so leaving them out would over-count.+ // Every filter the provider does not carry. `email` is absent because it stops+ // a candidate query being built at all. Adding a filter to+ // buildProgramEnrollmentWhereForList without adding it here or to the+ // document would silently over-count.const databaseOnlyFilters =Boolean(tenantId) ||Boolean(partnerIds?.length) ||+ Boolean(referredByPartnerId) ||Object.keys(buildMetricRangeWhere(enrollmentBase)).length > 0;if (diff --git a/apps/web/tests/partners/get-partners-count-search.test.ts b/apps/web/tests/partners/get-partners-count-search.test.tsindex ef852b5948..fe7d29c136 100644--- a/apps/web/tests/partners/get-partners-count-search.test.ts+++ b/apps/web/tests/partners/get-partners-count-search.test.ts@@ -75,6 +75,7 @@ describe("getPartnersCount search", () => {["a tenant ID", { tenantId: "tenant_1" }],["explicit partner IDs", { partnerIds: ["pn_1"] }],["a metric range", { totalClicksMin: 10 }],+ ["a referral filter", { referredByPartnerId: "pn_referrer" }],])("falls back to the database count when the provider cannot see %s",async (_label, extra) => {