diff --git a/app/models/collection.rb b/app/models/collection.rb index 5edc63e..f431033 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -77,6 +77,18 @@ def hosts projects.map(&:host).flatten.group_by(&:itself).transform_values(&:count).sort_by{|k,v| v}.reverse end + def contributors + combined_hash = Hash.new(0) + + projects.map(&:contributors).each do |contributors| + contributors.each do |k,v| + combined_hash[k] += v + end + end + + combined_hash.sort_by{|k,v| v}.reverse + end + def import_keyword(keyword) resp = Faraday.get("https://packages.ecosyste.ms/api/v1/keywords/#{keyword}?per_page=1000") if resp.status == 200 diff --git a/app/models/project.rb b/app/models/project.rb index 9235433..fb5bc9f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -8,6 +8,7 @@ class Project < ApplicationRecord scope :language, ->(language) { where("(repository ->> 'language') = ?", language) } scope :owner, ->(owner) { where("(repository ->> 'owner') = ?", owner) } scope :with_repository, -> { where.not(repository: nil) } + scope :with_issues, -> { where.not(issues: nil) } def self.sync_least_recently_synced Project.where(last_synced_at: nil).or(Project.where("last_synced_at < ?", 1.day.ago)).order('last_synced_at asc nulls first').limit(500).each do |project| @@ -244,6 +245,28 @@ def raw_committers commits["committers"] end + def contributors + return [] unless issues.present? + + combined_authors = issue_authors.merge(pull_request_authors) do |key, oldval, newval| + oldval + newval + end + + combined_authors + end + + def issue_authors + return {} unless issues.present? + return {} unless issues.issue_authors.present? + issues.issue_authors.to_h.map{|k,v| [k.downcase.to_s, v] }.to_h + end + + def pull_request_authors + return {} unless issues.present? + return {} unless issues.pull_request_authors.present? + issues.pull_request_authors.to_h.map{|k,v| [k.downcase.to_s, v] }.to_h + end + def fetch_dependencies return unless repository.present? conn = Faraday.new(url: repository['manifests_url']) do |faraday| diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index f15966e..c9f6a06 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -18,7 +18,7 @@ Keywords
- <% @collection.keywords.first(50).each do |keyword, count| %> + <% @collection.keywords.first(30).each do |keyword, count| %> <% next if keyword.blank? %> <%= keyword %> @@ -33,7 +33,7 @@ Languages
- <% @collection.languages.first(50).each do |keyword, count| %> + <% @collection.languages.first(30).each do |keyword, count| %> <% next if keyword.blank? %> <%= keyword %> @@ -43,12 +43,31 @@
+
+
+ Most Issues and Pull Requests +
+
+ <% @collection.contributors.first(30).each do |login, count| %> + <% next if login.blank? %> + + + <% end %> +
+
+
Committers
- <% @collection.committers.first(50).each do |keyword, count| %> + <% @collection.committers.first(30).each do |keyword, count| %> <% next if keyword.blank? %> <%= keyword %> @@ -63,7 +82,7 @@ Most Commits
- <% @collection.commits.first(50).each do |keyword, count| %> + <% @collection.commits.first(30).each do |keyword, count| %> <% next if keyword.blank? %> <%= keyword %> @@ -78,7 +97,7 @@ Direct Dependencies
- <% @collection.dependencies.first(50).each do |keyword, count| %> + <% @collection.dependencies.first(30).each do |keyword, count| %> <% next if keyword.blank? %> <%= keyword.join ':' %> @@ -96,7 +115,11 @@ <% @collection.owners.first(50).each do |owner, count| %> <% next if owner.blank? %> - <%= owner %> + + <%= owner %> + <%= owner %> + + <%= number_with_delimiter count%> <% end %>