1
This commit is contained in:
@@ -1856,8 +1856,8 @@ async def get_stats(
|
||||
)
|
||||
)).scalar() or 0
|
||||
|
||||
# ── 每日各模块积分消耗(按日期+模块分组)
|
||||
daily_credits_rows = (await db.execute(
|
||||
# ── 每日各模块积分消耗(按日期+模块分组,子查询排序避免 PG GROUP BY 限制)
|
||||
_daily_subq = (
|
||||
select(
|
||||
func.to_char(CreditRecord.created_at, 'YYYY-MM-DD').label('date'),
|
||||
func.coalesce(CreditRecord.source_module, 'other').label('module'),
|
||||
@@ -1869,7 +1869,11 @@ async def get_stats(
|
||||
CreditRecord.created_at <= date_end,
|
||||
)
|
||||
.group_by(func.to_char(CreditRecord.created_at, 'YYYY-MM-DD'), func.coalesce(CreditRecord.source_module, 'other'))
|
||||
.order_by(func.to_char(CreditRecord.created_at, 'YYYY-MM-DD'))
|
||||
.subquery()
|
||||
)
|
||||
daily_credits_rows = (await db.execute(
|
||||
select(_daily_subq.c.date, _daily_subq.c.module, _daily_subq.c.credits)
|
||||
.order_by(_daily_subq.c.date)
|
||||
)).all()
|
||||
daily_credits_by_module = [
|
||||
DailyCreditOut(date=row.date, module=row.module, credits=float(row.credits or 0))
|
||||
|
||||
Reference in New Issue
Block a user