[Update] 修复任务列表,执行历史中stat汇总数据显示问题

pull/4008/head
Bai 2020-05-19 15:15:17 +08:00
parent 728e4b7edd
commit 96afd82341
1 changed files with 6 additions and 3 deletions

View File

@ -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):