summaryrefslogtreecommitdiffstats
path: root/app/models/version.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-08 16:22:21 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2009-12-08 16:22:21 +0000
commit40e2af7ab97d051c312e8dbc762ca294be139009 (patch)
tree39ed092e6e113e3a87866a49d68d25a49859a188 /app/models/version.rb
parent517a87f8c52e121ae213490bacc5810208bf4152 (diff)
downloadredmine-40e2af7ab97d051c312e8dbc762ca294be139009.tar.gz
redmine-40e2af7ab97d051c312e8dbc762ca294be139009.zip
Optimize issue updates when a version sharing changes.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3135 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/version.rb')
-rw-r--r--app/models/version.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/version.rb b/app/models/version.rb
index add0dc734..fa9eb28e7 100644
--- a/app/models/version.rb
+++ b/app/models/version.rb
@@ -17,7 +17,7 @@
class Version < ActiveRecord::Base
before_destroy :check_integrity
- after_update :update_issue_versions
+ after_update :update_issues_from_sharing_change
belongs_to :project
has_many :fixed_issues, :class_name => 'Issue', :foreign_key => 'fixed_version_id'
acts_as_customizable
@@ -161,9 +161,13 @@ private
end
# Update the issue's fixed versions. Used if a version's sharing changes.
- def update_issue_versions
+ def update_issues_from_sharing_change
if sharing_changed?
- Issue.update_fixed_versions_from_project_hierarchy_change
+ if VERSION_SHARINGS.index(sharing_was).nil? ||
+ VERSION_SHARINGS.index(sharing).nil? ||
+ VERSION_SHARINGS.index(sharing_was) > VERSION_SHARINGS.index(sharing)
+ Issue.update_fixed_versions_from_sharing_change ['fixed_version_id = ?', id]
+ end
end
end