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.

Check the social metric count in the partiallyApproved backfill update

Rafi99f4c9753034
diff --git a/apps/web/scripts/migrations/backfill-bounty-partially-approved.ts b/apps/web/scripts/migrations/backfill-bounty-partially-approved.ts
index f5f1e6ebec..eb10ec5188 100644
--- a/apps/web/scripts/migrations/backfill-bounty-partially-approved.ts
+++ b/apps/web/scripts/migrations/backfill-bounty-partially-approved.ts
@@ -118,17 +118,26 @@ async function main() {
console.table(updates);
} else if (updates.length > 0) {
const results = await Promise.all(
- updates.map(({ id, approvedSocialMetricThreshold, from, to }) =>
- prisma.bountySubmission.updateMany({
- where: {
- id,
- status: from,
- approvedSocialMetricThreshold,
- },
- data: {
- status: to,
- },
- }),
+ updates.map(
+ ({
+ id,
+ socialMetricCount,
+ approvedSocialMetricThreshold,
+ from,
+ to,
+ }) =>
+ prisma.bountySubmission.updateMany({
+ where: {
+ id,
+ status: from,
+ approvedSocialMetricThreshold,
+ // Skips the row if a sync changed the count after we read it
+ socialMetricCount,
+ },
+ data: {
+ status: to,
+ },
+ }),
),
);