Wrap up AC-649, provide an api for the dashboard view

This commit is contained in:
Matthew Jones
2013-11-20 11:37:38 -05:00
parent 5a9bf7054c
commit d6cbcde0b4

View File

@@ -161,11 +161,18 @@ class DashboardView(APIView):
'failed': ec2_inventory_failed.count()}) 'failed': ec2_inventory_failed.count()})
user_groups = get_user_queryset(request.user, Group) user_groups = get_user_queryset(request.user, Group)
failed_group_inventory = [g.inventory for g in user_groups if g.inventory.has_active_failures]
group_with_job_failure = 0
for i in failed_group_inventory:
for j in i.jobs:
if j.failed:
group_with_job_failure += 1
break
data['groups'] = SortedDict({'url': reverse('api:group_list'), data['groups'] = SortedDict({'url': reverse('api:group_list'),
'failures_url': '__fill__', 'failures_url': reverse('api:group_list') + "?has_active_failures=True",
'total': user_groups.count(), 'total': user_groups.count(),
'job_failed': '__fill__', # # of groups with job failures 'job_failed': group_with_job_failure,
'inventory_failed': '__fill__'}) # # of groups with failed cloud updates 'inventory_failed': len(failed_group_inventory)})
user_hosts = get_user_queryset(request.user, Host) user_hosts = get_user_queryset(request.user, Host)
user_hosts_failed = user_hosts.filter(has_active_failures=True) user_hosts_failed = user_hosts.filter(has_active_failures=True)