fix pendingactions count
This commit is contained in:
@@ -218,8 +218,8 @@ class TestAuditViews(TacticalTestCase):
|
||||
r = self.client.patch(url, data, format="json")
|
||||
self.assertEqual(r.status_code, 200)
|
||||
self.assertEqual(len(r.data["actions"]), 12) # type: ignore
|
||||
self.assertEqual(r.data["completed_count"], 26) # type: ignore
|
||||
self.assertEqual(r.data["total"], 26) # type: ignore
|
||||
self.assertEqual(r.data["completed_count"], 12) # type: ignore
|
||||
self.assertEqual(r.data["total"], 12) # type: ignore
|
||||
|
||||
self.check_not_authenticated("patch", url)
|
||||
|
||||
|
||||
@@ -113,16 +113,24 @@ class PendingActions(APIView):
|
||||
actions = PendingAction.objects.filter(
|
||||
agent__pk=request.data["agentPK"], status=status_filter
|
||||
)
|
||||
total = PendingAction.objects.filter(
|
||||
agent__pk=request.data["agentPK"]
|
||||
).count()
|
||||
completed = PendingAction.objects.filter(
|
||||
agent__pk=request.data["agentPK"], status="completed"
|
||||
).count()
|
||||
|
||||
else:
|
||||
actions = PendingAction.objects.filter(status=status_filter).select_related(
|
||||
"agent"
|
||||
)
|
||||
total = PendingAction.objects.count()
|
||||
completed = PendingAction.objects.filter(status="completed").count()
|
||||
|
||||
ret = {
|
||||
"actions": PendingActionSerializer(actions, many=True).data,
|
||||
"completed_count": PendingAction.objects.filter(status="completed").count(),
|
||||
"total": PendingAction.objects.count(),
|
||||
"completed_count": completed,
|
||||
"total": total,
|
||||
}
|
||||
return Response(ret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user