Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scans, findings): Improve API performance ordering by inserted_at instead of id #6712

Merged
merged 2 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@

def get(self, request, *args, **kwargs):
spectacular_settings.TITLE = "Prowler API"
spectacular_settings.VERSION = "1.2.0"
spectacular_settings.VERSION = "1.3.1"

Check warning on line 197 in api/src/backend/api/v1/views.py

View check run for this annotation

Codecov / codecov/patch

api/src/backend/api/v1/views.py#L197

Added line #L197 was not covered by tests
spectacular_settings.DESCRIPTION = (
"Prowler API specification.\n\nThis file is auto-generated."
)
Expand Down Expand Up @@ -1306,9 +1306,8 @@
}
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 @@
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 @@
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 @@
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 @@
state=StateChoices.COMPLETED,
provider_id=OuterRef("scan__provider_id"),
)
.order_by("-id")
.order_by("-inserted_at")
.values("id")[:1]
)

Expand Down
Loading