add accounting errors monitoring card (accounting_status='failed')
This commit is contained in:
parent
a2a6e9a2d5
commit
fabd127e6f
@ -82,6 +82,17 @@ async def get_top_models(request):
|
||||
return result
|
||||
|
||||
|
||||
async def get_accounting_errors(request):
|
||||
"""获取当天记账错误笔数(accounting_status='failed')"""
|
||||
today = date.today().isoformat()
|
||||
env = request._run_ns
|
||||
async with get_sor_context(env, 'sage') as sor:
|
||||
sql = "SELECT COUNT(*) as cnt FROM llmusage WHERE use_date = ${today}$ AND accounting_status = 'failed'"
|
||||
recs = await sor.sqlExe(sql, {'today': today})
|
||||
cnt = int(recs[0].get('cnt', 0)) if recs else 0
|
||||
return cnt
|
||||
|
||||
|
||||
def load_dashboard():
|
||||
"""Register dashboard functions on ServerEnv"""
|
||||
g = ServerEnv()
|
||||
@ -90,3 +101,4 @@ def load_dashboard():
|
||||
g.get_total_users = get_total_users
|
||||
g.get_concurrent_users = get_concurrent_users
|
||||
g.get_top_models = get_top_models
|
||||
g.get_accounting_errors = get_accounting_errors
|
||||
|
||||
32
wwwroot/accounting_errors.ui
Normal file
32
wwwroot/accounting_errors.ui
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"bgcolor": "#FFFFFF",
|
||||
"padding": "24px",
|
||||
"borderRadius": "8px",
|
||||
"flex": "1",
|
||||
"minHeight": "120px",
|
||||
"boxShadow": "0 2px 8px rgba(0,0,0,0.1)"
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "记账错误笔数",
|
||||
"fontSize": "14px",
|
||||
"color": "#888",
|
||||
"marginBottom": "8px"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"id": "accounting_errors_value",
|
||||
"options": {
|
||||
"text": "{{get_accounting_errors(request)}}",
|
||||
"fontSize": "32px",
|
||||
"fontWeight": "bold",
|
||||
"color": "#ff4d4f"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -55,6 +55,14 @@
|
||||
"period_seconds": 10,
|
||||
"url": "{{entire_url('concurrent_users.ui')}}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "RefreshWidget",
|
||||
"id": "refresh_accounting_errors",
|
||||
"options": {
|
||||
"period_seconds": 10,
|
||||
"url": "{{entire_url('accounting_errors.ui')}}"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user