diff options
-rw-r--r-- | Gemfile | 2 | ||||
-rw-r--r-- | app/controllers/versions_controller.rb | 4 | ||||
-rw-r--r-- | app/models/version.rb | 2 | ||||
-rw-r--r-- | lib/redmine/helpers/gantt.rb | 24 |
4 files changed, 21 insertions, 11 deletions
@@ -11,7 +11,7 @@ gem 'marcel' gem 'mail', '~> 2.8.1' gem 'nokogiri', '~> 1.18.3' gem 'i18n', '~> 1.14.1' -gem 'rbpdf', '~> 1.21.3' +gem 'rbpdf', '~> 1.21.4' gem 'addressable' gem 'rubyzip', '~> 2.4.0' gem 'propshaft', '~> 1.1.0' diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index d52b43ba3..328d3e56e 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -51,7 +51,7 @@ class VersionsController < ApplicationController if @selected_tracker_ids.any? && @versions.any? issues = Issue.visible. includes(:project, :tracker). - preload(:status, :priority, :fixed_version). + preload(:status, :priority, :fixed_version, {:assigned_to => :email_address}). where(:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)). order("#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id") @issues_by_version = issues.group_by(&:fixed_version) @@ -69,7 +69,7 @@ class VersionsController < ApplicationController format.html do @issues = @version.fixed_issues.visible. includes(:status, :tracker, :priority). - preload(:project). + preload(:project, {:assigned_to => :email_address}). reorder("#{Tracker.table_name}.position, #{Issue.table_name}.id"). to_a end diff --git a/app/models/version.rb b/app/models/version.rb index 707ed59dc..3ca4f2bff 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -106,7 +106,7 @@ module FixedIssuesExtension done = self.open(open).sum do |c| estimated = c.total_estimated_hours.to_f estimated = estimated_average unless estimated > 0.0 - ratio = c.closed? ? 100 : (c.done_ratio || 0) + ratio = open ? (c.done_ratio || 0) : 100 estimated * ratio end progress = done / (estimated_average * issues_count) diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 5854a15f2..523ae3188 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -198,12 +198,18 @@ module Redmine # Returns the distinct versions of the issues that belong to +project+ def project_versions(project) - project_issues(project).filter_map(&:fixed_version).uniq + @project_versions ||= {} + @project_versions[project&.id] ||= begin + ids = project_issues(project).filter_map(&:fixed_version_id).uniq + Version.where(id: ids).to_a + end end # Returns the issues that belong to +project+ and are assigned to +version+ def version_issues(project, version) - project_issues(project).select {|issue| issue.fixed_version == version} + @version_issues ||= {} + @version_issues[[project&.id, version&.id]] ||= + project_issues(project).select {|issue| issue.fixed_version_id == version&.id} end def render(options={}) @@ -232,7 +238,7 @@ module Redmine render_object_row(project, options) increment_indent(options) do # render issue that are not assigned to a version - issues = project_issues(project).select {|i| i.fixed_version.nil?} + issues = project_issues(project).select {|i| i.fixed_version_id.nil?} render_issues(issues, options) # then render project versions and their issues versions = project_versions(project) @@ -748,7 +754,7 @@ module Redmine html_class << (version.behind_schedule? ? 'version-behind-schedule' : '') << " " html_class << (version.overdue? ? 'version-overdue' : '') html_class << ' version-closed' unless version.open? - if version.start_date && version.due_date && version.visible_fixed_issues.completed_percent + if version.due_date && version.start_date && version.visible_fixed_issues.completed_percent progress_date = calc_progress_date(version.start_date, version.due_date, version.visible_fixed_issues.completed_percent) html_class << ' behind-start-date' if progress_date < self.date_from @@ -778,10 +784,14 @@ module Redmine tag_options[:id] = "issue-#{object.id}" tag_options[:class] = "issue-subject hascontextmenu" tag_options[:title] = object.subject - children = object.leaf? ? [] : object.children & project_issues(object.project) has_children = - children.present? && - children.collect(&:fixed_version).uniq.intersect?([object.fixed_version]) + if object.leaf? + false + else + children = object.children & project_issues(object.project) + fixed_version_id = object.fixed_version_id + children.any? {|child| child.fixed_version_id == fixed_version_id} + end when Version tag_options[:id] = "version-#{object.id}" tag_options[:class] = "version-name" |