summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-08-07 04:44:19 +0000
committerGo MAEDA <maeda@farend.jp>2019-08-07 04:44:19 +0000
commit8a9123de04569aaaf0f8a337eaa8dbfb7fddd005 (patch)
treed0bc442048cd84e3514911b772a318e62b380b4b /app
parentbe7d39a4d3c2f567f4cc315969d6a5c09221fb45 (diff)
downloadredmine-8a9123de04569aaaf0f8a337eaa8dbfb7fddd005.tar.gz
redmine-8a9123de04569aaaf0f8a337eaa8dbfb7fddd005.zip
Limit total_estimated_hours to visible issues (#31778).
Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@18356 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/models/issue.rb2
-rw-r--r--app/models/issue_query.rb4
2 files changed, 3 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 0e5ac530a..507574de7 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1077,7 +1077,7 @@ class Issue < ActiveRecord::Base
if leaf?
estimated_hours
else
- @total_estimated_hours ||= self_and_descendants.sum(:estimated_hours)
+ @total_estimated_hours ||= self_and_descendants.visible.sum(:estimated_hours)
end
end
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 589089bad..5245d5ba0 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -40,8 +40,8 @@ class IssueQuery < Query
QueryColumn.new(:due_date, :sortable => "#{Issue.table_name}.due_date", :groupable => true),
QueryColumn.new(:estimated_hours, :sortable => "#{Issue.table_name}.estimated_hours", :totalable => true),
QueryColumn.new(:total_estimated_hours,
- :sortable => "COALESCE((SELECT SUM(estimated_hours) FROM #{Issue.table_name} subtasks" +
- " WHERE subtasks.root_id = #{Issue.table_name}.root_id AND subtasks.lft >= #{Issue.table_name}.lft AND subtasks.rgt <= #{Issue.table_name}.rgt), 0)",
+ :sortable => -> { "COALESCE((SELECT SUM(estimated_hours) FROM #{Issue.table_name} subtasks" +
+ " WHERE #{Issue.visible_condition(User.current).gsub(/\bissues\b/, 'subtasks')} AND subtasks.root_id = #{Issue.table_name}.root_id AND subtasks.lft >= #{Issue.table_name}.lft AND subtasks.rgt <= #{Issue.table_name}.rgt), 0)" },
:default_order => 'desc'),
QueryColumn.new(:done_ratio, :sortable => "#{Issue.table_name}.done_ratio", :groupable => true),
TimestampQueryColumn.new(:created_on, :sortable => "#{Issue.table_name}.created_on", :default_order => 'desc', :groupable => true),