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.

fix the negative values with usage

Kiran Ka6ba056e70f9
diff --git a/apps/web/app/api/domains/[domain]/transfer/route.ts b/apps/web/app/api/domains/[domain]/transfer/route.ts
index 5d7432061c..99233ca09d 100644
--- a/apps/web/app/api/domains/[domain]/transfer/route.ts
+++ b/apps/web/app/api/domains/[domain]/transfer/route.ts
@@ -103,6 +103,9 @@ export const POST = withAuth(
excludeRoot: true,
});
+ console.log({ usage: Math.max(workspace.usage - totalLinkClicks, 0) });
+ console.log({ linksUsage: Math.max(workspace.linksUsage - linksCount, 0) });
+
// Update the domain to use the new workspace
const [domainResponse] = await Promise.all([
prisma.domain.update({
@@ -123,10 +126,10 @@ export const POST = withAuth(
where: { id: workspace.id },
data: {
usage: {
- decrement: totalLinkClicks,
+ set: Math.max(workspace.usage - totalLinkClicks, 0),
},
linksUsage: {
- decrement: linksCount,
+ set: Math.max(workspace.linksUsage - linksCount, 0),
},
},
}),