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, }