fix(notifications): increase precision on billing calculations (#1283)

* update infra and remove railway

* fix(notifications): increase precision on billing calculations

* Revert "update infra and remove railway"

This reverts commit d17603e844.

* cleanup
This commit is contained in:
Waleed
2025-09-08 10:46:23 -07:00
committed by GitHub
parent 07e70409c7
commit 5218dd41b9
3 changed files with 4 additions and 4 deletions
@@ -35,7 +35,7 @@ export async function checkUsageStatus(userId: string): Promise<UsageData> {
: 0
return {
percentUsed: Math.min(Math.round((currentUsage / 1000) * 100), 100),
percentUsed: Math.min((currentUsage / 1000) * 100, 100),
isWarning: false,
isExceeded: false,
currentUsage,
@@ -69,7 +69,7 @@ export async function checkUsageStatus(userId: string): Promise<UsageData> {
)
// Calculate percentage used
const percentUsed = Math.min(Math.floor((currentUsage / limit) * 100), 100)
const percentUsed = Math.min((currentUsage / limit) * 100, 100)
// Check org-level cap for team/enterprise pooled usage
let isExceeded = currentUsage >= limit
+1 -1
View File
@@ -267,7 +267,7 @@ export async function getSimplifiedBillingSummary(
}
const overageAmount = Math.max(0, currentUsage - basePrice)
const percentUsed = usageData.limit > 0 ? Math.round((currentUsage / usageData.limit) * 100) : 0
const percentUsed = usageData.limit > 0 ? (currentUsage / usageData.limit) * 100 : 0
// Calculate days remaining in billing period
const daysRemaining = usageData.billingPeriodEnd
+1 -1
View File
@@ -86,7 +86,7 @@ export async function getUserUsageData(userId: string): Promise<UsageData> {
}
}
const percentUsed = limit > 0 ? Math.min(Math.floor((currentUsage / limit) * 100), 100) : 0
const percentUsed = limit > 0 ? Math.min((currentUsage / limit) * 100, 100) : 0
const isWarning = percentUsed >= 80
const isExceeded = currentUsage >= limit