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]