mirror of
https://github.com/langgenius/dify.git
synced 2026-04-23 12:16:11 +08:00
add:log
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import update
|
||||
@ -7,6 +8,8 @@ from core.errors.error import QuotaExceededError
|
||||
from extensions.ext_database import db
|
||||
from models import TenantCreditPool
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CreditPoolService:
|
||||
@classmethod
|
||||
@ -72,8 +75,9 @@ class CreditPoolService:
|
||||
cls,
|
||||
tenant_id: str,
|
||||
credits_required: int,
|
||||
) -> bool:
|
||||
):
|
||||
"""check and deduct credits"""
|
||||
logger.info("check and deduct credits")
|
||||
pool = cls.get_pool(tenant_id)
|
||||
if not pool:
|
||||
raise QuotaExceededError("Credit pool not found")
|
||||
@ -93,8 +97,6 @@ class CreditPoolService:
|
||||
stmt = update(TenantCreditPool).where(*where_conditions).values(**update_values)
|
||||
db.session.execute(stmt)
|
||||
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def check_deduct_credits(cls, tenant_id: str, credits_required: int) -> bool:
|
||||
"""check and deduct credits"""
|
||||
|
||||
Reference in New Issue
Block a user