Class: PredictabilityEngine::Calculators::Throughput
- Inherits:
-
Object
- Object
- PredictabilityEngine::Calculators::Throughput
- Defined in:
- lib/predictability_engine/calculators/throughput.rb
Class Method Summary collapse
- .average(work_items, start_date: nil, end_date: nil) ⇒ Object
- .daily(work_items, start_date: nil, end_date: nil) ⇒ Object
- .histogram_data(work_items) ⇒ Object
- .initial_daily_counts(start_date, end_date) ⇒ Object
- .populate_daily_counts(counts, completed, start_date, end_date) ⇒ Object
Class Method Details
.average(work_items, start_date: nil, end_date: nil) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/predictability_engine/calculators/throughput.rb', line 30 def self.average(work_items, start_date: nil, end_date: nil) counts = daily(work_items, start_date: start_date, end_date: end_date).values return 0 if counts.empty? counts.sum.to_f / counts.size end |
.daily(work_items, start_date: nil, end_date: nil) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/predictability_engine/calculators/throughput.rb', line 6 def self.daily(work_items, start_date: nil, end_date: nil) completed = work_items.select(&:completed?) return {} if completed.empty? start_date ||= completed.map(&:end_date).min end_date ||= completed.map(&:end_date).max counts = initial_daily_counts(start_date, end_date) populate_daily_counts(counts, completed, start_date, end_date) end |
.histogram_data(work_items) ⇒ Object
37 38 39 |
# File 'lib/predictability_engine/calculators/throughput.rb', line 37 def self.histogram_data(work_items) daily(work_items).values.tally.sort end |
.initial_daily_counts(start_date, end_date) ⇒ Object
17 18 19 |
# File 'lib/predictability_engine/calculators/throughput.rb', line 17 def self.initial_daily_counts(start_date, end_date) (start_date..end_date).to_h { |d| [d, 0] } end |
.populate_daily_counts(counts, completed, start_date, end_date) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/predictability_engine/calculators/throughput.rb', line 21 def self.populate_daily_counts(counts, completed, start_date, end_date) completed.each do |item| next if item.end_date < start_date || item.end_date > end_date counts[item.end_date] += 1 end counts end |