The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
code improvements
Pedro Ladeiracebb94985c24
diff --git a/apps/web/app/(ee)/api/cron/bounties/sync-social-metrics/route.ts b/apps/web/app/(ee)/api/cron/bounties/sync-social-metrics/route.tsindex dd84674a01..430f0c59e4 100644--- a/apps/web/app/(ee)/api/cron/bounties/sync-social-metrics/route.ts+++ b/apps/web/app/(ee)/api/cron/bounties/sync-social-metrics/route.ts@@ -1,3 +1,4 @@+import { getEffectiveBountyPeriod } from "@/lib/bounty/api/bounty-availability";import { getSocialMetricsUpdates } from "@/lib/bounty/api/get-social-metrics-updates";import { isBountyEnded } from "@/lib/bounty/bounty-period";import { hasReachedSocialMetricsEarningCap } from "@/lib/bounty/social-metrics-milestones";@@ -47,6 +48,10 @@ export const POST = withCron(async ({ rawBody }) => {return logAndRespond(`Bounty ${bountyId} not found. Skipping...`);}+ if (bounty.archivedAt) {+ return logAndRespond(`Bounty ${bountyId} is archived. Skipping...`);+ }+if (isBountyEnded(bounty.endsAt)) {return logAndRespond(`Bounty ${bountyId} has ended. Skipping...`);}@@ -91,6 +96,7 @@ export const POST = withCron(async ({ rawBody }) => {programEnrollment: {select: {partnerId: true,+ createdAt: true,},},},@@ -117,6 +123,15 @@ export const POST = withCron(async ({ rawBody }) => {return false;}+ const { endsAt } = getEffectiveBountyPeriod({+ programEnrollment: submission.programEnrollment,+ bounty,+ });++ if (isBountyEnded(endsAt)) {+ return false;+ }+return !hasReachedSocialMetricsEarningCap({ bounty, submission });});