Class: RubyMaat::Analysis::Churn::Ownership
- Inherits:
-
BaseAnalysis
- Object
- BaseAnalysis
- RubyMaat::Analysis::Churn::Ownership
- Defined in:
- lib/ruby_maat/analysis/churn.rb
Overview
Ownership analysis - churn metrics per author per entity
Instance Method Summary collapse
Instance Method Details
#analyze(dataset, _options = {}) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/ruby_maat/analysis/churn.rb', line 128 def analyze(dataset, = {}) # Group by entity and author results = {} dataset.to_df.each_row do |row| entity = row["entity"] = row["author"] added = row["loc_added"] || 0 deleted = row["loc_deleted"] || 0 key = [entity, ] results[key] ||= {entity: entity, author: , added: 0, deleted: 0} results[key][:added] += added results[key][:deleted] += deleted end # Sort by entity, then by total contribution descending sorted_results = results.values.sort do |a, b| entity_comparison = a[:entity] <=> b[:entity] if entity_comparison.zero? total_b = b[:added] + b[:deleted] total_a = a[:added] + a[:deleted] total_b <=> total_a else entity_comparison end end to_csv_data(sorted_results, i[entity added deleted]) end |