Class: KanbanMetrics::Commands::Cfd

Inherits:
Object
  • Object
show all
Defined in:
lib/kanban_metrics/commands/cfd.rb

Constant Summary collapse

USED_ATTRIBUTES =
[:committed, :started, :finished, :delivered]

Instance Method Summary collapse

Instance Method Details

#execute(work_items, start = nil, end_ = nil) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/kanban_metrics/commands/cfd.rb', line 5

def execute(work_items, start = nil, end_ = nil)
	chart_data = create_empty_chart_data_with_all_the_dates(work_items)

	work_items.each do |work_item|
		USED_ATTRIBUTES.each_with_index do |attribute, index|
			chart_data.keys.select {|date| attribute_lg_date?(work_item, attribute, date)}.each do |entry|
				chart_data[entry][index] += 1
			end
		end
	end

	start = earliest_date(work_items) if start.nil?
	end_ = latest_date(work_items) if end_.nil?
	chart_data.select! do |date, values|
			start <= date && date <= end_
	end

	ChartDataHelper.sort(chart_data)
end