kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.7 KiB
124 lines
3.7 KiB
11 years ago
|
#-- copyright
|
||
|
# OpenProject Backlogs Plugin
|
||
|
#
|
||
11 years ago
|
# Copyright (C)2013-2014 the OpenProject Foundation (OPF)
|
||
11 years ago
|
# Copyright (C)2011 Stephan Eckardt, Tim Felgentreff, Marnen Laibow-Koser, Sandro Munda
|
||
|
# Copyright (C)2010-2011 friflaj
|
||
|
# Copyright (C)2010 Maxime Guilbot, Andrew Vit, Joakim Kolsjö, ibussieres, Daniel Passos, Jason Vasquez, jpic, Emiliano Heyns
|
||
|
# Copyright (C)2009-2010 Mark Maglana
|
||
|
# Copyright (C)2009 Joe Heck, Nate Lowrie
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or modify it under
|
||
|
# the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# OpenProject Backlogs is a derivative work based on ChiliProject Backlogs.
|
||
|
# The copyright follows:
|
||
|
# Copyright (C) 2010-2011 - Emiliano Heyns, Mark Maglana, friflaj
|
||
|
# Copyright (C) 2011 - Jens Ulferts, Gregor Schmidt - Finn GmbH - Berlin, Germany
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
14 years ago
|
class Burndown
|
||
14 years ago
|
def initialize(sprint, project, burn_direction = nil)
|
||
9 years ago
|
burn_direction ||= Setting.plugin_openproject_backlogs['points_burn_direction']
|
||
14 years ago
|
|
||
14 years ago
|
@sprint_id = sprint.id
|
||
|
|
||
11 years ago
|
make_date_series sprint
|
||
14 years ago
|
|
||
12 years ago
|
series_data = OpenProject::Backlogs::Burndown::SeriesRawData.new(project,
|
||
11 years ago
|
sprint,
|
||
9 years ago
|
points: ['story_points'])
|
||
14 years ago
|
|
||
9 years ago
|
series_data.collect_data
|
||
14 years ago
|
|
||
14 years ago
|
calculate_series series_data
|
||
|
|
||
|
determine_max
|
||
14 years ago
|
end
|
||
|
|
||
14 years ago
|
attr_reader :days
|
||
|
attr_reader :sprint_id
|
||
|
attr_reader :max
|
||
14 years ago
|
|
||
14 years ago
|
attr_reader :story_points
|
||
|
attr_reader :story_points_ideal
|
||
14 years ago
|
|
||
9 years ago
|
def series(_select = :active)
|
||
14 years ago
|
@available_series
|
||
14 years ago
|
end
|
||
|
|
||
14 years ago
|
private
|
||
14 years ago
|
|
||
9 years ago
|
def make_date_series(sprint)
|
||
14 years ago
|
@days = sprint.days
|
||
14 years ago
|
end
|
||
|
|
||
9 years ago
|
def calculate_series(series_data)
|
||
9 years ago
|
series_data.collect_names.each do |c|
|
||
13 years ago
|
# need to differentiate between hours and sp
|
||
9 years ago
|
make_series c.to_sym, series_data.unit_for(c), series_data[c].to_a.sort_by(&:first).map(&:last)
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
14 years ago
|
calculate_ideals(series_data)
|
||
|
end
|
||
14 years ago
|
|
||
14 years ago
|
def calculate_ideals(data)
|
||
9 years ago
|
(['story_points'] & data.collect_names).each do |ideal|
|
||
14 years ago
|
calculate_ideal(ideal, data.unit_for(ideal))
|
||
14 years ago
|
end
|
||
14 years ago
|
end
|
||
|
|
||
14 years ago
|
def calculate_ideal(name, unit)
|
||
9 years ago
|
max = send(name).first || 0.0
|
||
|
delta = max / (days.size - 1)
|
||
14 years ago
|
|
||
14 years ago
|
ideal = []
|
||
9 years ago
|
days.each_with_index do |_d, i|
|
||
14 years ago
|
ideal[i] = max - delta * i
|
||
|
end
|
||
14 years ago
|
|
||
9 years ago
|
make_series name.to_s + '_ideal', unit, ideal
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
|
def make_series(name, units, data)
|
||
|
@available_series ||= {}
|
||
12 years ago
|
s = OpenProject::Backlogs::Burndown::Series.new(data, name, units)
|
||
14 years ago
|
@available_series[name] = s
|
||
|
instance_variable_set("@#{name}", s)
|
||
|
end
|
||
|
|
||
|
def determine_max
|
||
|
@max = {
|
||
9 years ago
|
points: @available_series.values.select { |s| s.unit == :points }.flatten.compact.reject(&:nan?).max || 0.0,
|
||
|
hours: @available_series.values.select { |s| s.unit == :hours }.flatten.compact.reject(&:nan?).max || 0.0
|
||
14 years ago
|
}
|
||
|
end
|
||
|
|
||
|
def to_h(keys, values)
|
||
9 years ago
|
Hash[*keys.zip(values).flatten]
|
||
14 years ago
|
end
|
||
|
|
||
|
def workday_before(date = Date.today)
|
||
|
d = date - 1
|
||
9 years ago
|
# TODO: make weekday configurable
|
||
|
d = workday_before(d) unless d.wday > 0 and d.wday < 6
|
||
14 years ago
|
d
|
||
|
end
|
||
|
end
|