2025-07-16 14:28:41 +08:00

26 lines
567 B
Plaintext

ns = params_kw.copy()
sql = """select a.*, b.name as miname, c.name as mtname,
concat(b.name, '(', c.name, ')') as name from
(select modelinstanceid as mii,
modeltypeid as mti,
avg(finish_time) as cost_time
from feelog
where transdate >= ${start_date}$ and
transdate < ${end_date}$ and
finish_time is not null
group by mii, mti
) a,
modelinstance b,
modeltype as c
where a.mii = b.id and
a.mti = c.id
order by cost_time
limit 5
"""
db = DBPools()
async with db.sqlorContext('sage') as sor:
recs = await sor.sqlExe(sql, ns.copy())
return recs
return []