Skip to content

Commit

Permalink
Add vulnerable_package_count property on Project model #600
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Druez <[email protected]>
  • Loading branch information
tdruez committed Jul 5, 2023
1 parent 4547b54 commit faf3d26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,11 @@ def package_count(self):
"""Return the number of packages related to this project."""
return self.discoveredpackages.count()

@cached_property
def vulnerable_package_count(self):
"""Return the number of vulnerable packages related to this project."""
return self.discoveredpackages.vulnerable().count()

@cached_property
def dependency_count(self):
"""Return the number of dependencies related to this project."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<a href="{% url 'project_packages' project.slug %}">
{{ project.package_count|intcomma }}
</a>
{% if project.discoveredpackages.vulnerable.count %}
{% if project.vulnerable_package_count %}
<a href="{% url 'project_packages' project.slug %}?is_vulnerable=yes" class="has-text-danger is-size-5 ml-2">
{{ project.discoveredpackages.vulnerable.count|intcomma }}
{{ project.vulnerable_package_count|intcomma }}
<i class="fa-solid fa-bug is-size-6"></i>
</a>
{% endif %}
Expand Down

0 comments on commit faf3d26

Please sign in to comment.