mirror of
https://github.com/ansible/awx.git
synced 2026-04-22 10:20:24 -02:30
Remove the hosts count from related_field_counts in the org api endpoints
It is probably not needed, and adds an additional db query.
This commit is contained in:
@@ -1259,7 +1259,7 @@ class OrganizationSerializer(BaseSerializer):
|
||||
if counts_dict is not None and summary_dict is not None:
|
||||
if obj.id not in counts_dict:
|
||||
summary_dict['related_field_counts'] = {
|
||||
'inventories': 0, 'teams': 0, 'users': 0, 'hosts': 0,
|
||||
'inventories': 0, 'teams': 0, 'users': 0,
|
||||
'job_templates': 0, 'admins': 0, 'projects': 0}
|
||||
else:
|
||||
summary_dict['related_field_counts'] = counts_dict[obj.id]
|
||||
|
||||
@@ -29,7 +29,7 @@ from awx.main.models.ha import (
|
||||
)
|
||||
from awx.main.models.organization import Team
|
||||
from awx.main.models.projects import Project
|
||||
from awx.main.models.inventory import Inventory, Host
|
||||
from awx.main.models.inventory import Inventory
|
||||
from awx.main.models.jobs import JobTemplate
|
||||
from awx.conf.license import (
|
||||
feature_enabled,
|
||||
@@ -235,8 +235,6 @@ class OrganizationCountsMixin(object):
|
||||
db_results['projects'] = project_qs\
|
||||
.values('organization').annotate(Count('organization')).order_by('organization')
|
||||
|
||||
db_results['hosts'] = Host.objects.active_counts_by_org()
|
||||
|
||||
# Other members and admins of organization are always viewable
|
||||
db_results['users'] = org_qs.annotate(
|
||||
users=Count('member_role__members', distinct=True),
|
||||
@@ -248,7 +246,7 @@ class OrganizationCountsMixin(object):
|
||||
org_id = org['id']
|
||||
count_context[org_id] = {
|
||||
'inventories': 0, 'teams': 0, 'users': 0, 'job_templates': 0,
|
||||
'admins': 0, 'projects': 0, 'hosts': 0}
|
||||
'admins': 0, 'projects': 0}
|
||||
|
||||
for res, count_qs in db_results.items():
|
||||
if res == 'job_templates_project':
|
||||
@@ -257,8 +255,6 @@ class OrganizationCountsMixin(object):
|
||||
org_reference = JT_inventory_reference
|
||||
elif res == 'users':
|
||||
org_reference = 'id'
|
||||
elif res == 'hosts':
|
||||
org_reference = 'inventory__organization'
|
||||
else:
|
||||
org_reference = 'organization'
|
||||
for entry in count_qs:
|
||||
|
||||
@@ -17,7 +17,6 @@ from awx.conf.license import (
|
||||
from awx.main.models import (
|
||||
ActivityStream,
|
||||
Inventory,
|
||||
Host,
|
||||
Project,
|
||||
JobTemplate,
|
||||
WorkflowJobTemplate,
|
||||
@@ -120,7 +119,6 @@ class OrganizationDetail(RelatedJobsPreventDeleteMixin, RetrieveUpdateDestroyAPI
|
||||
organization__id=org_id).count()
|
||||
org_counts['job_templates'] = JobTemplate.accessible_objects(**access_kwargs).filter(
|
||||
project__organization__id=org_id).count()
|
||||
org_counts['hosts'] = Host.objects.org_active_count(org_id)
|
||||
|
||||
full_context['related_field_counts'] = {}
|
||||
full_context['related_field_counts'][org_id] = org_counts
|
||||
|
||||
Reference in New Issue
Block a user