File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -397,25 +397,27 @@ export async function triggerMonthlyResetAndGrant(params: {
397397 . set ( { next_quota_reset : newResetDate } )
398398 . where ( eq ( schema . user . id , userId ) )
399399
400- // Always grant free credits
401- await processAndGrantCredit ( {
400+ // Always grant free credits - use grantCreditOperation with tx to keep everything in the same transaction
401+ await grantCreditOperation ( {
402402 ...params ,
403403 amount : freeGrantAmount ,
404404 type : 'free' ,
405405 description : 'Monthly free credits' ,
406406 expiresAt : newResetDate , // Free credits expire at next reset
407407 operationId : freeOperationId ,
408+ tx,
408409 } )
409410
410411 // Only grant referral credits if there are any
411412 if ( referralBonus > 0 ) {
412- await processAndGrantCredit ( {
413+ await grantCreditOperation ( {
413414 ...params ,
414415 amount : referralBonus ,
415416 type : 'referral' ,
416417 description : 'Monthly referral bonus' ,
417418 expiresAt : newResetDate , // Referral credits expire at next reset
418419 operationId : referralOperationId ,
420+ tx,
419421 } )
420422 }
421423
You can’t perform that action at this time.
0 commit comments