From 4677bca1aded1c99bdbb9b405f8d5630e3a5917c Mon Sep 17 00:00:00 2001 From: "Jorge Alberto Diaz Orozco (Akiel)" Date: Sun, 22 Sep 2024 13:58:24 +0200 Subject: [PATCH] Move all filtering on the ports endpoint to the query --- proxylist/views.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/proxylist/views.py b/proxylist/views.py index 013d398..b85d8be 100644 --- a/proxylist/views.py +++ b/proxylist/views.py @@ -175,14 +175,13 @@ class PortViewSet(viewsets.ViewSet): @method_decorator(cache_page(20 * 60)) def list(self, request, format=None): - ports = [ - port - for port in Proxy.objects.filter(is_active=True) + ports = ( + Proxy.objects.filter(is_active=True, port__gt=0) .values_list("port", flat=True) .distinct() - if port != 0 - ] - ports.sort() + .order_by("port") + ) + ports = [ { "port": port,