1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

Merge pull request #4105 from rooftopcellist/fix_instance_counts

Fixes analytics & metrics instance specific job counts

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-06-19 16:49:09 +00:00 committed by GitHub
commit c585c3d07d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,7 +156,7 @@ def projects_by_scm_type(since):
@register('instance_info') @register('instance_info')
def instance_info(since): def instance_info(since):
info = {} info = {}
instances = models.Instance.objects.values_list('hostname').annotate().values( instances = models.Instance.objects.values_list('hostname').values(
'uuid', 'version', 'capacity', 'cpu', 'memory', 'managed_by_policy', 'hostname', 'last_isolated_check', 'enabled') 'uuid', 'version', 'capacity', 'cpu', 'memory', 'managed_by_policy', 'hostname', 'last_isolated_check', 'enabled')
for instance in instances: for instance in instances:
instance_info = { instance_info = {
@ -187,12 +187,12 @@ def job_counts(since):
def job_instance_counts(since): def job_instance_counts(since):
counts = {} counts = {}
job_types = models.UnifiedJob.objects.exclude(launch_type='sync').values_list( job_types = models.UnifiedJob.objects.exclude(launch_type='sync').values_list(
'execution_node', 'launch_type').annotate(job_launch_type=Count('launch_type')) 'execution_node', 'launch_type').annotate(job_launch_type=Count('launch_type')).order_by()
for job in job_types: for job in job_types:
counts.setdefault(job[0], {}).setdefault('launch_type', {})[job[1]] = job[2] counts.setdefault(job[0], {}).setdefault('launch_type', {})[job[1]] = job[2]
job_statuses = models.UnifiedJob.objects.exclude(launch_type='sync').values_list( job_statuses = models.UnifiedJob.objects.exclude(launch_type='sync').values_list(
'execution_node', 'status').annotate(job_status=Count('status')) 'execution_node', 'status').annotate(job_status=Count('status')).order_by()
for job in job_statuses: for job in job_statuses:
counts.setdefault(job[0], {}).setdefault('status', {})[job[1]] = job[2] counts.setdefault(job[0], {}).setdefault('status', {})[job[1]] = job[2]
return counts return counts