Gantt perf: fixed that Project#start_date and #due_date run way too much queries.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11135 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+10
-8
@@ -289,6 +289,8 @@ class Project < ActiveRecord::Base
|
||||
@allowed_parents = nil
|
||||
@allowed_permissions = nil
|
||||
@actions_allowed = nil
|
||||
@start_date = nil
|
||||
@due_date = nil
|
||||
super
|
||||
end
|
||||
|
||||
@@ -538,20 +540,20 @@ class Project < ActiveRecord::Base
|
||||
|
||||
# The earliest start date of a project, based on it's issues and versions
|
||||
def start_date
|
||||
[
|
||||
@start_date ||= [
|
||||
issues.minimum('start_date'),
|
||||
shared_versions.collect(&:effective_date),
|
||||
shared_versions.collect(&:start_date)
|
||||
].flatten.compact.min
|
||||
shared_versions.minimum('effective_date'),
|
||||
Issue.fixed_version(shared_versions).minimum('start_date')
|
||||
].compact.min
|
||||
end
|
||||
|
||||
# The latest due date of an issue or version
|
||||
def due_date
|
||||
[
|
||||
@due_date ||= [
|
||||
issues.maximum('due_date'),
|
||||
shared_versions.collect(&:effective_date),
|
||||
shared_versions.collect {|v| v.fixed_issues.maximum('due_date')}
|
||||
].flatten.compact.max
|
||||
shared_versions.maximum('effective_date'),
|
||||
Issue.fixed_version(shared_versions).maximum('due_date')
|
||||
].compact.max
|
||||
end
|
||||
|
||||
def overdue?
|
||||
|
||||
Reference in New Issue
Block a user