3rd_fix download

This commit is contained in:
beabigegg
2025-09-02 16:47:16 +08:00
parent b11a8272c4
commit e6e5332705
24 changed files with 1671 additions and 167 deletions

View File

@@ -66,9 +66,13 @@ class User(db.Model):
def get_total_cost(self):
"""計算使用者總成本"""
return db.session.query(
func.sum(self.api_usage_stats.cost)
).scalar() or 0.0
try:
from app.models.stats import APIUsageStats
return db.session.query(
func.sum(APIUsageStats.cost)
).filter(APIUsageStats.user_id == self.id).scalar() or 0.0
except Exception:
return 0.0
def update_last_login(self):
"""更新最後登入時間"""