From 2814f875783b6e71491005f04331a42b7fd84cbb Mon Sep 17 00:00:00 2001 From: javayhu Date: Sun, 10 Aug 2025 13:53:48 +0800 Subject: [PATCH] feat: update user last refresh time and refine user selection criteria --- src/credits/credits.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/credits/credits.ts b/src/credits/credits.ts index a6c5ce7..d4348f8 100644 --- a/src/credits/credits.ts +++ b/src/credits/credits.ts @@ -447,6 +447,9 @@ export async function addMonthlyFreeCredits(userId: string) { expireDays, }); + // Update last refresh time for free monthly credits + await updateUserLastRefreshAt(userId, now); + console.log( `addMonthlyFreeCredits, ${credits} credits for user ${userId}, date: ${now.getFullYear()}-${now.getMonth() + 1}` ); @@ -571,7 +574,7 @@ export async function distributeCreditsToAllUsers() { name: user.name, }) .from(user) - .where(not(eq(user.banned, true))); // Only active users, banned is null by default + .where(or(isNull(user.banned), eq(user.banned, false))); console.log('distribute credits, users count:', users.length); let processedCount = 0;