Skip to content

Commit

Permalink
Revert undesired changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Henrique Dias Junqueira de Souza committed Oct 21, 2024
1 parent ec02423 commit 08256e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dojo/endpoint/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def process_endpoints_view(request, host_view=False, vulnerable=False):
else:
endpoints = Endpoint.objects.all()

endpoints = endpoints.prefetch_related("product", "product__tags", "tags").distinct()
endpoints = endpoints.prefetch_related("product", "product__tags", "tags", "findings").distinct()
endpoints = get_authorized_endpoints(Permissions.Endpoint_View, endpoints, request.user)
endpoints = endpoints.annotate(active_finding_count=Count("findings", filter=Q(findings__active=True)))
endpoints = endpoints.annotate(findings_count=Count("findings", filter=Q(findings__active=True)))

filter_string_matching = get_system_setting("filter_string_matching", False)
filter_class = EndpointFilterWithoutObjectLookups if filter_string_matching else EndpointFilter
Expand Down
4 changes: 2 additions & 2 deletions dojo/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2393,10 +2393,10 @@ class EndpointFilterHelper(FilterSet):
fields=(
("product", "product"),
("host", "host"),
("av_findings_count", "av_findings_count"),
("findings_count", "findings_count"),
),
field_labels={
"av_findings_count": "Findings Count ",
"findings_count": "Findings Count ",
}
)

Expand Down
10 changes: 2 additions & 8 deletions dojo/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1839,15 +1839,9 @@ def vulnerable(self):
risk_accepted=False,
).count() > 0

@cached_property
@property
def findings_count(self):
try:
# if prefetched, it's already there
return self.active_finding_count
except AttributeError:
# ideally it's always prefetched and we can remove this code in the future
self.active_finding_count = self.findings.all().count()
return self.active_finding_count
return self.findings.all().count()

def active_findings(self):
return self.findings.filter(
Expand Down

0 comments on commit 08256e4

Please sign in to comment.