Skip to content

Commit 52ad26a

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

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
@@ -1189,6 +1189,11 @@ def dependency_count(self):
11891189
"""Return the number of dependencies related to this project."""
11901190
return self.discovereddependencies.count()
11911191

1192+
@cached_property
1193+
def license_detections_count(self):
1194+
"""Return the number of license detections in this project."""
1195+
return self.discoveredlicenses.count()
1196+
11921197
@cached_property
11931198
def message_count(self):
11941199
"""Return the number of messages related to this project."""
@@ -3427,7 +3432,7 @@ def as_spdx(self):
34273432
class DiscoveredLicenseQuerySet(ProjectRelatedQuerySet):
34283433
def order_by_count_and_expression(self):
34293434
"""Order by detection count and license expression (identifer) fields."""
3430-
return self.order_by("detection_count", "identifier")
3435+
return self.order_by("-detection_count", "identifier")
34313436

34323437

34333438
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)