4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/kanban_metrics/commands/io.rb', line 4
def execute(work_items, start = nil, end_ = nil)
chart_data = {}
work_items.each do |work_item|
in_ = "#{work_item.started.year}-#{work_item.started.cweek}"
out = "#{work_item.delivered.year}-#{work_item.delivered.cweek}"
if chart_data[in_].nil?
chart_data[in_] = [0, 0]
end
if chart_data[out].nil?
chart_data[out] = [0, 0]
end
chart_data[in_][0] += 1
chart_data[out][1] += 1
end
start = earliest_started(work_items) if start.nil?
end_ = latest_delivered(work_items) if end_.nil?
start_cweek = "#{start.year}-#{start.cweek}"
end_cweek = "#{end_.year}-#{end_.cweek}"
chart_data.select! do |date, values|
start_cweek <= date && date <= end_cweek
end
ChartDataHelper.sort(chart_data)
end
|