From 1ca9af7a285aa56497a10ce07201baf81cd63595 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 22 Jul 2026 11:33:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=AA=E8=A1=A8=E7=9B=98=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=8E=BB=E6=8E=89call=5Fdate=3Dtoday=E9=99=90?= =?UTF-8?q?=E5=88=B6,=E6=98=BE=E7=A4=BA=E5=85=A8=E9=87=8F=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sage_datamart/dashboards.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sage_datamart/dashboards.py b/sage_datamart/dashboards.py index 08412bf..0912ef6 100644 --- a/sage_datamart/dashboards.py +++ b/sage_datamart/dashboards.py @@ -190,10 +190,10 @@ async def get_currency_breakdown(env, sor): COALESCE(SUM(amount), 0) as amount, COALESCE(SUM(amount_cny), 0) as amount_cny FROM dm_model_call_fact - WHERE call_date = ${today}$ + WHERE 1=1 GROUP BY dm_model_call_fact.currency ORDER BY call_count DESC""" - recs = await sor.sqlExe(sql, {'today': env.curDateString()}) + recs = await sor.sqlExe(sql, {}) return [{ 'currency': r.currency or 'CNY', 'call_count': int(r.call_count), @@ -205,21 +205,21 @@ async def get_currency_breakdown(env, sor): # ── 排行榜 ── async def get_top_models(env, sor, limit=5): - """当天 Top N 模型(按调用次数)""" + """Top N 模型(按调用次数,全量)""" sql = """SELECT model, COUNT(*) as cnt, COALESCE(SUM(amount_cny), 0) as total_amount - FROM dm_model_call_fact WHERE call_date = ${today}$ + FROM dm_model_call_fact GROUP BY model ORDER BY cnt DESC LIMIT ${limit}$""" - recs = await sor.sqlExe(sql, {'today': env.curDateString(), 'limit': limit}) + recs = await sor.sqlExe(sql, {'limit': limit}) return [{'model_name': r.model or 'Unknown', 'cnt': int(r.cnt), 'total_amount': round(float(r.total_amount), 2)} for r in recs] async def get_top_providers(env, sor, limit=5): - """当天 Top N 供应商(按金额)""" + """Top N 供应商(按金额,全量)""" sql = """SELECT providerid, COUNT(*) as cnt, COALESCE(SUM(amount_cny), 0) as total_amount - FROM dm_model_call_fact WHERE call_date = ${today}$ AND providerid IS NOT NULL + FROM dm_model_call_fact WHERE providerid IS NOT NULL GROUP BY providerid ORDER BY total_amount DESC LIMIT ${limit}$""" - recs = await sor.sqlExe(sql, {'today': env.curDateString(), 'limit': limit}) + recs = await sor.sqlExe(sql, {'limit': limit}) return [{'provider_name': r.providerid or 'Unknown', 'cnt': int(r.cnt), 'total_amount': round(float(r.total_amount), 2)} for r in recs] @@ -282,11 +282,11 @@ async def get_daily_trend(env, sor, days=7): async def get_hourly_concurrency(env, sor): - """当天每小时并发(活跃用户)""" + """每小时并发(全量)""" sql = """SELECT call_hour, COUNT(DISTINCT userid) as users, COUNT(*) as calls - FROM dm_model_call_fact WHERE call_date = ${today}$ + FROM dm_model_call_fact GROUP BY call_hour ORDER BY call_hour""" - recs = await sor.sqlExe(sql, {'today': env.curDateString()}) + recs = await sor.sqlExe(sql, {}) return [{'hour': r.call_hour, 'users': int(r.users), 'calls': int(r.calls)} for r in recs]