From 53ec34f6e38f8dff34ffbad430ff38b6443d6693 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 13:28:03 +0100 Subject: [PATCH 01/14] limit amount of highstates being looked up --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 55141ae6..50212010 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ) + ).order_by('jid').desc()[0:10] states = sorted(states, key=lambda x: x.jid, reverse=True) # Remove jobs with arguments. From d8f8a5ca307b1c2973224745b2e26af5711a3e1b Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:10:08 +0100 Subject: [PATCH 02/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 50212010..6417fa1e 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ).order_by('jid').desc()[0:10] + ).order_by('jid').first() states = sorted(states, key=lambda x: x.jid, reverse=True) # Remove jobs with arguments. From e2b95d14ef31c71071cad77a21f6b61390934a2c Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:15:30 +0100 Subject: [PATCH 03/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 6417fa1e..86135b6c 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ).order_by('jid').first() + ).order_by('jid')[0:2] states = sorted(states, key=lambda x: x.jid, reverse=True) # Remove jobs with arguments. From eb26d7e3a27191f8d9e03ff8c4c7b2650e7485c1 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:21:56 +0100 Subject: [PATCH 04/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 86135b6c..3c2ec710 100644 --- a/api/models.py +++ b/api/models.py @@ -146,7 +146,7 @@ def last_highstate(self): states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id ).order_by('jid')[0:2] - states = sorted(states, key=lambda x: x.jid, reverse=True) + states = sorted(states, key=lambda x: x.jid) # Remove jobs with arguments. for state in states: From d5bc299e8fa787f370c2471b0da3416a86b46656 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:24:08 +0100 Subject: [PATCH 05/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 3c2ec710..b0bac848 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ).order_by('jid')[0:2] + ).order_by('-jid')[0:2] states = sorted(states, key=lambda x: x.jid) # Remove jobs with arguments. From 230d734f4b937452194196172c7542585c1a256b Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:50:17 +0100 Subject: [PATCH 06/14] lower amount of jobs loaded by default on jid's --- api/views/salt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/views/salt.py b/api/views/salt.py index e37d6bcf..96f5ebd7 100644 --- a/api/views/salt.py +++ b/api/views/salt.py @@ -35,7 +35,7 @@ def get_queryset(self): qry = {} start = self.request.query_params.get("start", None) end = self.request.query_params.get("end", None) - limit = int(self.request.query_params.get("limit", 200)) + limit = int(self.request.query_params.get("limit", 50)) target = self.request.query_params.getlist("target[]") users = self.request.query_params.getlist("users[]", None) if target: From ebb34f4bedc5c45c7d0dfb55223c744aec91df8f Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:56:37 +0100 Subject: [PATCH 07/14] more tuning --- api/views/salt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/views/salt.py b/api/views/salt.py index 96f5ebd7..ea630b0b 100644 --- a/api/views/salt.py +++ b/api/views/salt.py @@ -57,8 +57,8 @@ class SaltReturnsListJid(generics.ListAPIView): def get_queryset(self): jid = self.kwargs["jid"] - queryset = SaltReturns.objects.all() - return queryset.filter(jid=jid).order_by("-alter_time") + queryset = SaltReturns.objects.filter(jid=jid).order_by("-alter_time") + return queryset @api_view(["GET"]) @@ -97,5 +97,5 @@ class EventsViewSet(viewsets.ReadOnlyModelViewSet): A simple ViewSet for viewing accounts. """ - queryset = SaltEvents.objects.all().order_by("-alter_time")[:200] + queryset = SaltEvents.objects.all().order_by("-alter_time")[:50] serializer_class = EventsSerializer From 5ae5fed3685a500e9e218bd1318b9f8e6f03b762 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 13:28:03 +0100 Subject: [PATCH 08/14] limit amount of highstates being looked up --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 55141ae6..50212010 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ) + ).order_by('jid').desc()[0:10] states = sorted(states, key=lambda x: x.jid, reverse=True) # Remove jobs with arguments. From f1dc73535d1bdd0223a4821bfe0d05ea2aab117e Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:10:08 +0100 Subject: [PATCH 09/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 50212010..6417fa1e 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ).order_by('jid').desc()[0:10] + ).order_by('jid').first() states = sorted(states, key=lambda x: x.jid, reverse=True) # Remove jobs with arguments. From 08be7b450a2a3016dbba6bfed17edf4094829b57 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:15:30 +0100 Subject: [PATCH 10/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 6417fa1e..86135b6c 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ).order_by('jid').first() + ).order_by('jid')[0:2] states = sorted(states, key=lambda x: x.jid, reverse=True) # Remove jobs with arguments. From dfc712477474a9f50179314636ee00bda253e640 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:21:56 +0100 Subject: [PATCH 11/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 86135b6c..3c2ec710 100644 --- a/api/models.py +++ b/api/models.py @@ -146,7 +146,7 @@ def last_highstate(self): states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id ).order_by('jid')[0:2] - states = sorted(states, key=lambda x: x.jid, reverse=True) + states = sorted(states, key=lambda x: x.jid) # Remove jobs with arguments. for state in states: From 9c7813273ae3948a663238f9567cb83b4d2d7352 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 14:24:08 +0100 Subject: [PATCH 12/14] Update models.py --- api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/models.py b/api/models.py index 3c2ec710..b0bac848 100644 --- a/api/models.py +++ b/api/models.py @@ -145,7 +145,7 @@ def last_highstate(self): # Get all potential jobs. states = SaltReturns.objects.filter( Q(fun="state.apply") | Q(fun="state.highstate"), id=self.minion_id - ).order_by('jid')[0:2] + ).order_by('-jid')[0:2] states = sorted(states, key=lambda x: x.jid) # Remove jobs with arguments. From 896c4a79ceee10417ff602e1f76dc147f62364d6 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 19:50:17 +0100 Subject: [PATCH 13/14] lower amount of jobs loaded by default on jid's --- api/views/salt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/views/salt.py b/api/views/salt.py index e37d6bcf..96f5ebd7 100644 --- a/api/views/salt.py +++ b/api/views/salt.py @@ -35,7 +35,7 @@ def get_queryset(self): qry = {} start = self.request.query_params.get("start", None) end = self.request.query_params.get("end", None) - limit = int(self.request.query_params.get("limit", 200)) + limit = int(self.request.query_params.get("limit", 50)) target = self.request.query_params.getlist("target[]") users = self.request.query_params.getlist("users[]", None) if target: From 0228bee71d273284eeac5ccf05c6ffe4bb075c21 Mon Sep 17 00:00:00 2001 From: "Jamie (Bear) Murphy" <1613241+ITJamie@users.noreply.github.com> Date: Tue, 21 Jun 2022 22:56:37 +0100 Subject: [PATCH 14/14] more tuning --- api/views/salt.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/views/salt.py b/api/views/salt.py index 96f5ebd7..ea630b0b 100644 --- a/api/views/salt.py +++ b/api/views/salt.py @@ -57,8 +57,8 @@ class SaltReturnsListJid(generics.ListAPIView): def get_queryset(self): jid = self.kwargs["jid"] - queryset = SaltReturns.objects.all() - return queryset.filter(jid=jid).order_by("-alter_time") + queryset = SaltReturns.objects.filter(jid=jid).order_by("-alter_time") + return queryset @api_view(["GET"]) @@ -97,5 +97,5 @@ class EventsViewSet(viewsets.ReadOnlyModelViewSet): A simple ViewSet for viewing accounts. """ - queryset = SaltEvents.objects.all().order_by("-alter_time")[:200] + queryset = SaltEvents.objects.all().order_by("-alter_time")[:50] serializer_class = EventsSerializer