The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
address CR feedback
Steven Tey177a525795e8
diff --git a/apps/web/app/(ee)/api/cron/payouts/reconcile-amounts/route.ts b/apps/web/app/(ee)/api/cron/payouts/reconcile-amounts/route.tsindex 7919b45ee5..574d4d0b66 100644--- a/apps/web/app/(ee)/api/cron/payouts/reconcile-amounts/route.ts+++ b/apps/web/app/(ee)/api/cron/payouts/reconcile-amounts/route.ts@@ -2,6 +2,7 @@ import { reconcilePayoutAmounts } from "@/lib/api/commissions/reconcile-payout-aimport { withCron } from "@/lib/cron/with-cron";import { prisma } from "@/lib/prisma";import { withRedisLock } from "@/lib/upstash/redis-lock";+import { chunk } from "@dub/utils";import { PayoutStatus } from "@prisma/client";import { subMinutes } from "date-fns";import { logAndRespond } from "../../utils";@@ -34,6 +35,11 @@ export const GET = withCron(async () => {gte: updatedAfter,},status: PayoutStatus.pending,+ ...(startingAfter && {+ id: {+ gt: startingAfter,+ },+ }),},select: {id: true,@@ -43,12 +49,6 @@ export const GET = withCron(async () => {orderBy: {id: "asc",},- ...(startingAfter && {- skip: 1,- cursor: {- id: startingAfter,- },- }),});if (payouts.length === 0) {@@ -99,10 +99,14 @@ export const GET = withCron(async () => {if (mismatches.length > 0) {console.table(mismatches);- await reconcilePayoutAmounts(+ const payoutIdChunks = chunk(mismatches.map((mismatch) => mismatch.id),+ 50,);- fixed += mismatches.length;+ for (const payoutIdChunk of payoutIdChunks) {+ await reconcilePayoutAmounts(payoutIdChunk);+ fixed += payoutIdChunk.length;+ }}if (payouts.length < BATCH_SIZE) {