File tree Expand file tree Collapse file tree
app/(ee)/api/partner-profile/programs/[programId] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { getAnalytics } from "@/lib/analytics/get-analytics";
22import { DubApiError } from "@/lib/api/errors" ;
33import { getProgramEnrollmentOrThrow } from "@/lib/api/programs/get-program-enrollment-or-throw" ;
44import { withPartnerProfile } from "@/lib/auth/partner" ;
5+ import { MAX_PARTNER_LINKS_FOR_LOCAL_FILTERING } from "@/lib/constants/partner-profile" ;
56import {
67 LARGE_PROGRAM_IDS ,
78 LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS ,
@@ -52,7 +53,11 @@ export const GET = withPartnerProfile(
5253 ? { event : rest . event , groupBy : "count" , interval : "all" }
5354 : rest ) ,
5455 workspaceId : program . workspaceId ,
55- ...( linkId ? { linkId } : { linkIds : links . map ( ( link ) => link . id ) } ) ,
56+ ...( linkId
57+ ? { linkId }
58+ : links . length > MAX_PARTNER_LINKS_FOR_LOCAL_FILTERING
59+ ? { partnerId : partner . id }
60+ : { linkIds : links . map ( ( link ) => link . id ) } ) ,
5661 dataAvailableFrom : program . startedAt ?? program . createdAt ,
5762 } ) ;
5863
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { getEvents } from "@/lib/analytics/get-events";
22import { DubApiError } from "@/lib/api/errors" ;
33import { getProgramEnrollmentOrThrow } from "@/lib/api/programs/get-program-enrollment-or-throw" ;
44import { withPartnerProfile } from "@/lib/auth/partner" ;
5+ import { MAX_PARTNER_LINKS_FOR_LOCAL_FILTERING } from "@/lib/constants/partner-profile" ;
56import {
67 LARGE_PROGRAM_IDS ,
78 LARGE_PROGRAM_MIN_TOTAL_COMMISSIONS_CENTS ,
@@ -68,7 +69,11 @@ export const GET = withPartnerProfile(
6869 const events = await getEvents ( {
6970 ...rest ,
7071 workspaceId : program . workspaceId ,
71- ...( linkId ? { linkId } : { linkIds : links . map ( ( link ) => link . id ) } ) ,
72+ ...( linkId
73+ ? { linkId }
74+ : links . length > MAX_PARTNER_LINKS_FOR_LOCAL_FILTERING
75+ ? { partnerId : partner . id }
76+ : { linkIds : links . map ( ( link ) => link . id ) } ) ,
7277 dataAvailableFrom : program . startedAt ?? program . createdAt ,
7378 } ) ;
7479
Original file line number Diff line number Diff line change 11export const MAX_INVITES_PER_REQUEST = 5 ;
22export const MAX_PARTNER_USERS = 10 ;
3+ export const MAX_PARTNER_LINKS_FOR_LOCAL_FILTERING = 100 ; // if over 100 links we should filter on TB directly
You can’t perform that action at this time.
0 commit comments