Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

refactor(monthly-usage-checker): streamline site limit handling

Bill Yangb81ad85ef62d
diff --git a/server/src/cron/monthly-usage-checker.ts b/server/src/cron/monthly-usage-checker.ts
index 5bc9cc723..c09745333 100644
--- a/server/src/cron/monthly-usage-checker.ts
+++ b/server/src/cron/monthly-usage-checker.ts
@@ -190,9 +190,6 @@ export async function updateUsersMonthlyUsage() {
);
try {
- // Clear the previous list of sites over their limit
- sitesOverLimit.clear();
-
// Get all users with their Stripe customer ID
const users = await db
.select({
@@ -240,6 +237,10 @@ export async function updateUsersMonthlyUsage() {
console.log(
`[Monthly Usage Checker] User ${userData.email} is over limit. Added ${siteIds.length} sites to blocked list.`
);
+ } else {
+ for (const siteId of siteIds) {
+ sitesOverLimit.delete(siteId);
+ }
}
// Format additional date info for logging if available