From dbcf33ff8ca923ad18b941057a25ccb55072ad0e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 23 Jul 2026 11:17:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20get=5Frealtime=5Fstats=E7=94=A8int(r.xxx?= =?UTF-8?q?=20or=200)=E6=9B=BF=E4=BB=A3hasattr,=E5=A4=84=E7=90=86SQL?= =?UTF-8?q?=E8=BF=94=E5=9B=9ENULL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sage_datamart/dashboards.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sage_datamart/dashboards.py b/sage_datamart/dashboards.py index 0addfc0..ed0503c 100644 --- a/sage_datamart/dashboards.py +++ b/sage_datamart/dashboards.py @@ -104,13 +104,13 @@ async def get_realtime_stats(sor, today, scope=None, org_filter=None): recs = await sor.sqlExe(sql, ns) if recs: r = recs[0] - total = int(r.calls) if hasattr(r, 'calls') else r.get('calls', 0) - success = int(r.success) if hasattr(r, 'success') else r.get('success', 0) - fail = int(r.fail) if hasattr(r, 'fail') else r.get('fail', 0) + total = int(r.calls or 0) + success = int(r.success or 0) + fail = int(r.fail or 0) return { 'calls': total, - 'amount': round(float(r.amount) if hasattr(r, 'amount') else r.get('amount', 0), 2), - 'active_users': int(r.active_users) if hasattr(r, 'active_users') else r.get('active_users', 0), + 'amount': round(float(r.amount or 0), 2), + 'active_users': int(r.active_users or 0), 'success_rate': round(success * 100.0 / total, 1) if total else 0, 'fail_count': fail, }