fixed slow dashboard loading due to bad query
@@ -7,7 +7,7 @@ import time
from pathlib import Path
from django.conf import settings
-from django.db.models import Count, Exists, OuterRef, Prefetch, Q
+from django.db.models import Count, Exists, Prefetch, Q
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.utils import timezone as djangotime
@@ -140,14 +140,10 @@ class GetAgents(APIView):
pending_actions_count=Count(
"pendingactions",
filter=Q(pendingactions__status=PAStatus.PENDING),
- )
- )
- .annotate(
+ ),
has_patches_pending=Exists(
- WinUpdate.objects.filter(
- agent_id=OuterRef("pk"), action="approve", installed=False
- )
- )
+ WinUpdate.objects.filter(action="approve", installed=False)
+ ),
)
)
serializer = AgentTableSerializer(agents, many=True)
