mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
fix: 统计聚合中成本字段 float 改 Decimal,修复与数据库 Numeric
字段相加的类型错误
This commit is contained in:
@@ -9,6 +9,7 @@ import os
|
|||||||
import uuid
|
import uuid
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from datetime import date, datetime, time, timedelta, timezone
|
from datetime import date, datetime, time, timedelta, timezone
|
||||||
|
from decimal import Decimal
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from sqlalchemy import Float, and_, case, cast, func
|
from sqlalchemy import Float, and_, case, cast, func
|
||||||
@@ -961,8 +962,8 @@ class StatsAggregatorService:
|
|||||||
summary.all_time_output_tokens = int(daily_aggregated.output_tokens or 0)
|
summary.all_time_output_tokens = int(daily_aggregated.output_tokens or 0)
|
||||||
summary.all_time_cache_creation_tokens = int(daily_aggregated.cache_creation_tokens or 0)
|
summary.all_time_cache_creation_tokens = int(daily_aggregated.cache_creation_tokens or 0)
|
||||||
summary.all_time_cache_read_tokens = int(daily_aggregated.cache_read_tokens or 0)
|
summary.all_time_cache_read_tokens = int(daily_aggregated.cache_read_tokens or 0)
|
||||||
summary.all_time_cost = float(daily_aggregated.total_cost or 0)
|
summary.all_time_cost = Decimal(str(daily_aggregated.total_cost or 0))
|
||||||
summary.all_time_actual_cost = float(daily_aggregated.actual_total_cost or 0)
|
summary.all_time_actual_cost = Decimal(str(daily_aggregated.actual_total_cost or 0))
|
||||||
summary.total_users = total_users
|
summary.total_users = total_users
|
||||||
summary.active_users = active_users
|
summary.active_users = active_users
|
||||||
summary.total_api_keys = total_api_keys
|
summary.total_api_keys = total_api_keys
|
||||||
@@ -1010,8 +1011,8 @@ class StatsAggregatorService:
|
|||||||
"output_tokens": 0,
|
"output_tokens": 0,
|
||||||
"cache_creation_tokens": 0,
|
"cache_creation_tokens": 0,
|
||||||
"cache_read_tokens": 0,
|
"cache_read_tokens": 0,
|
||||||
"total_cost": 0.0,
|
"total_cost": Decimal(0),
|
||||||
"actual_total_cost": 0.0,
|
"actual_total_cost": Decimal(0),
|
||||||
"avg_response_time_ms": 0.0,
|
"avg_response_time_ms": 0.0,
|
||||||
"unique_models": 0,
|
"unique_models": 0,
|
||||||
"unique_providers": 0,
|
"unique_providers": 0,
|
||||||
@@ -1027,8 +1028,8 @@ class StatsAggregatorService:
|
|||||||
"output_tokens": int(getattr(aggregated, "output_tokens", 0) or 0),
|
"output_tokens": int(getattr(aggregated, "output_tokens", 0) or 0),
|
||||||
"cache_creation_tokens": int(getattr(aggregated, "cache_creation_tokens", 0) or 0),
|
"cache_creation_tokens": int(getattr(aggregated, "cache_creation_tokens", 0) or 0),
|
||||||
"cache_read_tokens": int(getattr(aggregated, "cache_read_tokens", 0) or 0),
|
"cache_read_tokens": int(getattr(aggregated, "cache_read_tokens", 0) or 0),
|
||||||
"total_cost": float(getattr(aggregated, "total_cost", 0) or 0.0),
|
"total_cost": Decimal(str(getattr(aggregated, "total_cost", 0) or 0)),
|
||||||
"actual_total_cost": float(getattr(aggregated, "actual_total_cost", 0) or 0.0),
|
"actual_total_cost": Decimal(str(getattr(aggregated, "actual_total_cost", 0) or 0)),
|
||||||
"avg_response_time_ms": float(getattr(aggregated, "avg_response_time", 0) or 0.0),
|
"avg_response_time_ms": float(getattr(aggregated, "avg_response_time", 0) or 0.0),
|
||||||
"unique_models": int(getattr(aggregated, "unique_models", 0) or 0),
|
"unique_models": int(getattr(aggregated, "unique_models", 0) or 0),
|
||||||
"unique_providers": int(getattr(aggregated, "unique_providers", 0) or 0),
|
"unique_providers": int(getattr(aggregated, "unique_providers", 0) or 0),
|
||||||
|
|||||||
Reference in New Issue
Block a user