Skip to content

Commit 206fe2b

Browse files
Add License Detections in project summary
Signed-off-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com>
1 parent e73da98 commit 206fe2b

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

scanpipe/models.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,11 @@ def dependency_count(self):
12291229
"""Return the number of dependencies related to this project."""
12301230
return self.discovereddependencies.count()
12311231

1232+
@cached_property
1233+
def license_detections_count(self):
1234+
"""Return the number of license detections in this project."""
1235+
return self.discoveredlicenses.count()
1236+
12321237
@cached_property
12331238
def message_count(self):
12341239
"""Return the number of messages related to this project."""
@@ -3477,7 +3482,7 @@ def as_spdx(self):
34773482
class DiscoveredLicenseQuerySet(ProjectRelatedQuerySet):
34783483
def order_by_count_and_expression(self):
34793484
"""Order by detection count and license expression (identifer) fields."""
3480-
return self.order_by("detection_count", "identifier")
3485+
return self.order_by("-detection_count", "identifier")
34813486

34823487

34833488
class AbstractLicenseDetection(models.Model):

scanpipe/templates/scanpipe/includes/project_summary_level.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@
4040
</p>
4141
</div>
4242
</div>
43+
<div class="level-item has-text-centered">
44+
<div>
45+
<p class="heading">License Detections</p>
46+
<p class="{{ title_class }} is-flex is-align-items-center is-justify-content-center">
47+
{% if project.license_detections_count %}
48+
<a href="{% url 'project_licenses' project.slug %}">
49+
{{ project.license_detections_count|intcomma }}
50+
</a>
51+
{% else %}
52+
<span>0</span>
53+
{% endif %}
54+
</p>
55+
</div>
56+
</div>
4357
<div class="level-item has-text-centered">
4458
<div>
4559
<p class="heading">Resources</p>

0 commit comments

Comments
 (0)