Class: RubyMaat::Analysis::Effort::MainDeveloperByRevisions
- Inherits:
-
BaseAnalysis
- Object
- BaseAnalysis
- RubyMaat::Analysis::Effort::MainDeveloperByRevisions
- Defined in:
- lib/ruby_maat/analysis/effort.rb
Overview
Main developer by revisions - primary contributor per entity (by commit count)
Instance Method Summary collapse
Instance Method Details
#analyze(dataset, options = {}) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ruby_maat/analysis/effort.rb', line 59 def analyze(dataset, = {}) min_revs = [:min_revs] || 5 # Group by entity and author, count revisions = {} dataset.to_df.each_row do |row| entity = row["entity"] = row["author"] revision = row["revision"] [entity] ||= {} [entity][] ||= Set.new [entity][] << revision end # Find main developer for each entity results = [] .each do |entity, | total_revisions = .values.sum(&:size) next if total_revisions < min_revs # Find author with most revisions , revisions = .max_by { |, revs| revs.size } total_revisions = .values.sum(&:size) results << { entity: entity, "main-dev": , added: revisions.size, # Number of revisions by main dev "total-added": total_revisions, ownership: total_revisions.positive? ? (revisions.size.to_f / total_revisions).round(2) : 0.0 } end # Sort by number of revisions descending results.sort_by! { |r| -r[:added] } to_csv_data(results, %i[entity main-dev added total-added ownership]) end |