File tree Expand file tree Collapse file tree 3 files changed +38
-6
lines changed Expand file tree Collapse file tree 3 files changed +38
-6
lines changed Original file line number Diff line number Diff line change @@ -633,6 +633,26 @@ def ping_commits
633
633
return unless repo_metadata . present?
634
634
ecosystems_api_get ( "#{ commits_api_url } /ping" )
635
635
end
636
+
637
+ def fetch_commit_stats
638
+ return unless commits_api_url . present?
639
+ ecosystems_api_get ( "#{ commits_api_url } /stats" )
640
+ rescue
641
+ nil
642
+ end
643
+
644
+ # Fetches commit stats from the commits service and stores in repo_metadata['commit_stats']
645
+ # This provides an alternative to relying on the repos service to load commit data
646
+ def update_commit_stats
647
+ return unless repo_metadata . present?
648
+
649
+ commit_stats = fetch_commit_stats
650
+ if commit_stats . present?
651
+ updated_metadata = repo_metadata . deep_dup
652
+ updated_metadata [ 'commit_stats' ] = commit_stats
653
+ update ( repo_metadata : updated_metadata )
654
+ end
655
+ end
636
656
637
657
def sync_maintainers
638
658
registry . sync_maintainers ( self )
Original file line number Diff line number Diff line change 26
26
<% end %>
27
27
</ small >
28
28
29
- <% if package . issue_metadata . present? || package . commit_stats . present? %>
29
+ <% if package . issue_metadata . present? || package . commit_stats . present? || package . repo_metadata &. dig ( 'commit_stats' ) . present? %>
30
30
< br >
31
31
< small class ='text-muted '>
32
- <% committers_count = package . commit_stats &.dig ( 'total_committers' ) %>
32
+ <% committers_count = package . commit_stats &.dig ( 'total_committers' ) || package . repo_metadata &. dig ( 'commit_stats' , 'total_committers' ) %>
33
33
<% issue_authors_count = package . issue_metadata &.dig ( 'past_year_issue_authors_count' ) %>
34
34
<% pr_authors_count = package . issue_metadata &.dig ( 'past_year_pull_request_authors_count' ) %>
35
35
<% maintainers_count = package . issue_metadata &.dig ( 'maintainers' ) &.length %>
61
61
<% any_stats = true %>
62
62
<% end %>
63
63
64
- <% dds_score = package . issue_metadata &.dig ( 'dds' ) || package . commit_stats &.dig ( 'dds' ) %>
64
+ <% dds_score = package . issue_metadata &.dig ( 'dds' ) || package . commit_stats &.dig ( 'dds' ) || package . repo_metadata &. dig ( 'commit_stats' , 'dds' ) %>
65
65
<% if dds_score && dds_score > 0 %>
66
66
<%= '- ' if any_stats %> <%= number_with_delimiter ( dds_score ) %> DDS
67
67
<% end %>
Original file line number Diff line number Diff line change @@ -12,7 +12,13 @@ class CriticalControllerTest < ActionDispatch::IntegrationTest
12
12
maintainers_count : 1 ,
13
13
downloads : 1000 ,
14
14
dependent_packages_count : 5 ,
15
- dependent_repos_count : 10
15
+ dependent_repos_count : 10 ,
16
+ issue_metadata : {
17
+ 'past_year_issue_authors_count' => 25 ,
18
+ 'past_year_pull_request_authors_count' => 12 ,
19
+ 'maintainers' => [ { 'login' => 'test-maintainer' } ] ,
20
+ 'active_maintainers' => [ { 'login' => 'test-maintainer' } ]
21
+ }
16
22
)
17
23
18
24
@critical_package . maintainers << @maintainer
@@ -44,7 +50,10 @@ class CriticalControllerTest < ActionDispatch::IntegrationTest
44
50
ecosystem : 'pypi' ,
45
51
name : 'other-package' ,
46
52
critical : true ,
47
- maintainers_count : 1
53
+ maintainers_count : 1 ,
54
+ issue_metadata : {
55
+ 'past_year_issue_authors_count' => 15
56
+ }
48
57
)
49
58
50
59
get critical_sole_maintainers_path ( registry : @registry . name )
@@ -59,7 +68,10 @@ class CriticalControllerTest < ActionDispatch::IntegrationTest
59
68
name : 'high-download-package' ,
60
69
critical : true ,
61
70
maintainers_count : 1 ,
62
- downloads : 5000
71
+ downloads : 5000 ,
72
+ issue_metadata : {
73
+ 'past_year_issue_authors_count' => 30
74
+ }
63
75
)
64
76
65
77
get critical_sole_maintainers_path
You can’t perform that action at this time.
0 commit comments