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 get-eligible-payouts.ts

Tim Wilson8d55be623956
diff --git a/apps/web/lib/api/payouts/get-eligible-payouts.ts b/apps/web/lib/api/payouts/get-eligible-payouts.ts
index 1669ea5c2a..63bee340c8 100644
--- a/apps/web/lib/api/payouts/get-eligible-payouts.ts
+++ b/apps/web/lib/api/payouts/get-eligible-payouts.ts
@@ -143,6 +143,24 @@ export async function getEligiblePayoutsCount({
selectedPayoutId,
excludedPayoutIds,
}: Omit<GetEligiblePayoutsProps, "pageSize" | "page">) {
+ const cutoffPeriodValue = CUTOFF_PERIOD.find(
+ (c) => c.id === cutoffPeriod,
+ )?.value;
+
+ // Requires special re-computing and filtering of payouts, so we just have to fetch all of them
+ if (cutoffPeriodValue)
+ return (
+ await getEligiblePayouts({
+ program,
+ cutoffPeriod,
+ selectedPayoutId,
+ excludedPayoutIds,
+ pageSize: Infinity,
+ page: 1,
+ })
+ ).length;
+
+ // Simple count
return await prisma.payout.count({
where: getEligiblePayoutsWhere({
program,