From 96afd82341199a431f9b25c7b2ebb8e6829e0199 Mon Sep 17 00:00:00 2001 From: Bai Date: Tue, 19 May 2020 15:15:17 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E6=89=A7=E8=A1=8C=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E4=B8=ADstat=E6=B1=87=E6=80=BB=E6=95=B0=E6=8D=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/ops/serializers/adhoc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/ops/serializers/adhoc.py b/apps/ops/serializers/adhoc.py index afdd659fc..8d9e18e24 100644 --- a/apps/ops/serializers/adhoc.py +++ b/apps/ops/serializers/adhoc.py @@ -19,10 +19,13 @@ class AdHocExecutionSerializer(serializers.ModelSerializer): @staticmethod def get_stat(obj): + count_failed_hosts = len(obj.failed_hosts) + count_success_hosts = len(obj.success_hosts) + count_total = count_success_hosts + count_failed_hosts return { - "total": obj.hosts_amount, - "success": len(obj.summary.get("contacted", [])), - "failed": len(obj.summary.get("dark", [])), + "total": count_total, + "success": count_success_hosts, + "failed": count_failed_hosts } def get_field_names(self, declared_fields, info):