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.

Improve importer efficiency

Steven Tey97599b75221d
diff --git a/apps/web/lib/partnerstack/import-commissions.ts b/apps/web/lib/partnerstack/import-commissions.ts
index 7c2f8446aa..d654d3f823 100644
--- a/apps/web/lib/partnerstack/import-commissions.ts
+++ b/apps/web/lib/partnerstack/import-commissions.ts
@@ -152,15 +152,13 @@ async function createCommission({
const trackedCommission = await prisma.commission.findFirst({
where: {
programId,
- type: "sale",
- customer: {
- id: customer.id,
- },
- amount: commission.transaction.amount,
createdAt: {
gte: new Date(chargedAt.getTime() - 60 * 60 * 1000), // 1 hour before
lte: new Date(chargedAt.getTime() + 60 * 60 * 1000), // 1 hour after
},
+ customerId: customer.id,
+ type: "sale",
+ amount: commission.transaction.amount,
},
});
diff --git a/apps/web/lib/rewardful/import-commissions.ts b/apps/web/lib/rewardful/import-commissions.ts
index 9a6d8a153f..be9aa5466b 100644
--- a/apps/web/lib/rewardful/import-commissions.ts
+++ b/apps/web/lib/rewardful/import-commissions.ts
@@ -147,15 +147,15 @@ async function createCommission({
const trackedCommission = await prisma.commission.findFirst({
where: {
programId: program.id,
- type: "sale",
- customer: {
- stripeCustomerId: sale.referral.stripe_customer_id,
- },
- amount: sale.sale_amount_cents,
createdAt: {
gte: new Date(chargedAt.getTime() - 60 * 60 * 1000), // 1 hour before
lte: new Date(chargedAt.getTime() + 60 * 60 * 1000), // 1 hour after
},
+ customer: {
+ stripeCustomerId: sale.referral.stripe_customer_id,
+ },
+ type: "sale",
+ amount: sale.sale_amount_cents,
},
});
diff --git a/apps/web/lib/tolt/import-commissions.ts b/apps/web/lib/tolt/import-commissions.ts
index 2179deb79d..86535ffcfa 100644
--- a/apps/web/lib/tolt/import-commissions.ts
+++ b/apps/web/lib/tolt/import-commissions.ts
@@ -182,15 +182,13 @@ async function createCommission({
const trackedCommission = await prisma.commission.findFirst({
where: {
programId,
- type: "sale",
- customer: {
- id: customerFound.id,
- },
- amount: Number(sale.amount),
createdAt: {
gte: new Date(chargedAt.getTime() - 60 * 60 * 1000), // 1 hour before
lte: new Date(chargedAt.getTime() + 60 * 60 * 1000), // 1 hour after
},
+ customerId: customerFound.id,
+ type: "sale",
+ amount: Number(sale.amount),
},
});