Skip to content

Commit

Permalink
fix(scans, findings): Improve API performance ordering by inserted_at…
Browse files Browse the repository at this point in the history
… instead of id (#6712)

Co-authored-by: Víctor Fernández Poyatos <[email protected]>
Co-authored-by: Pepe Fagoaga <[email protected]>
  • Loading branch information
3 people authored Jan 28, 2025
1 parent b5d8364 commit 282fe3d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 39 deletions.
60 changes: 30 additions & 30 deletions api/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ description = "Prowler's API (Django/DRF)"
license = "Apache-2.0"
name = "prowler-api"
package-mode = false
version = "1.3.0"
version = "1.3.1"

[tool.poetry.dependencies]
celery = {extras = ["pytest"], version = "^5.4.0"}
Expand Down
2 changes: 1 addition & 1 deletion api/src/backend/api/specs/v1.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: Prowler API
version: 1.2.0
version: 1.3.1
description: |-
Prowler API specification.
Expand Down
13 changes: 6 additions & 7 deletions api/src/backend/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class SchemaView(SpectacularAPIView):

def get(self, request, *args, **kwargs):
spectacular_settings.TITLE = "Prowler API"
spectacular_settings.VERSION = "1.2.0"
spectacular_settings.VERSION = "1.3.1"
spectacular_settings.DESCRIPTION = (
"Prowler API specification.\n\nThis file is auto-generated."
)
Expand Down Expand Up @@ -1306,9 +1306,8 @@ class FindingViewSet(BaseRLSViewSet):
}
http_method_names = ["get"]
filterset_class = FindingFilter
ordering = ["-id"]
ordering = ["-inserted_at"]
ordering_fields = [
"id",
"status",
"severity",
"check_id",
Expand Down Expand Up @@ -2006,7 +2005,7 @@ def providers(self, request):
uid=OuterRef("uid"),
scan__provider=OuterRef("scan__provider"),
)
.order_by("-id") # Most recent by id
.order_by("-inserted_at") # Most recent
.values("id")[:1]
)

Expand Down Expand Up @@ -2075,7 +2074,7 @@ def findings(self, request):
state=StateChoices.COMPLETED,
provider_id=OuterRef("scan__provider_id"),
)
.order_by("-id")
.order_by("-inserted_at")
.values("id")[:1]
)

Expand Down Expand Up @@ -2120,7 +2119,7 @@ def findings_severity(self, request):
state=StateChoices.COMPLETED,
provider_id=OuterRef("scan__provider_id"),
)
.order_by("-id")
.order_by("-inserted_at")
.values("id")[:1]
)

Expand Down Expand Up @@ -2156,7 +2155,7 @@ def services(self, request):
state=StateChoices.COMPLETED,
provider_id=OuterRef("scan__provider_id"),
)
.order_by("-id")
.order_by("-inserted_at")
.values("id")[:1]
)

Expand Down

0 comments on commit 282fe3d

Please sign in to comment.