fix: LIMIT语法错误 - str(limit)导致LIMIT '5',改为int
This commit is contained in:
parent
993c293b56
commit
52acdbbfab
@ -209,7 +209,7 @@ async def get_top_models(env, sor, limit=5):
|
||||
sql = """SELECT model, COUNT(*) as cnt, COALESCE(SUM(amount_cny), 0) as total_amount
|
||||
FROM dm_model_call_fact WHERE call_date = ${today}$
|
||||
GROUP BY model ORDER BY cnt DESC LIMIT ${limit}$"""
|
||||
recs = await sor.sqlExe(sql, {'today': env.curDateString(), 'limit': str(limit)})
|
||||
recs = await sor.sqlExe(sql, {'today': env.curDateString(), '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]
|
||||
|
||||
@ -219,7 +219,7 @@ async def get_top_providers(env, sor, limit=5):
|
||||
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
|
||||
GROUP BY providerid ORDER BY total_amount DESC LIMIT ${limit}$"""
|
||||
recs = await sor.sqlExe(sql, {'today': env.curDateString(), 'limit': str(limit)})
|
||||
recs = await sor.sqlExe(sql, {'today': env.curDateString(), '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]
|
||||
|
||||
@ -228,7 +228,7 @@ async def get_top_users(env, sor, limit=5):
|
||||
"""全量 Top N 用户(按金额)"""
|
||||
sql = """SELECT userid, COUNT(*) as cnt, COALESCE(SUM(amount_cny), 0) as total_amount
|
||||
FROM dm_model_call_fact GROUP BY userid ORDER BY total_amount DESC LIMIT ${limit}$"""
|
||||
recs = await sor.sqlExe(sql, {'limit': str(limit)})
|
||||
recs = await sor.sqlExe(sql, {'limit': limit})
|
||||
return [{'user_name': r.userid, 'cnt': int(r.cnt),
|
||||
'total_amount': round(float(r.total_amount), 2)} for r in recs]
|
||||
|
||||
@ -313,7 +313,7 @@ async def get_distributor_top_customers(sor, distributor_orgid, limit=5):
|
||||
sql = """SELECT userorgid, COUNT(*) as cnt, COALESCE(SUM(amount_cny), 0) as total_amount
|
||||
FROM dm_model_call_fact WHERE distributor_orgid = ${org}$
|
||||
GROUP BY userorgid ORDER BY total_amount DESC LIMIT ${limit}$"""
|
||||
recs = await sor.sqlExe(sql, {'org': distributor_orgid, 'limit': str(limit)})
|
||||
recs = await sor.sqlExe(sql, {'org': distributor_orgid, 'limit': limit})
|
||||
return [{'org_id': r.userorgid, 'cnt': int(r.cnt),
|
||||
'total_amount': round(float(r.total_amount), 2)} for r in recs]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user