diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-18 13:05:46 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2011-12-18 13:05:46 +0000 |
commit | 2a0257e8af822b1e3022479b213ca4bf7d0ef903 (patch) | |
tree | d2031022eda4a73bcb58cbc5fc93a04fac858da8 /app/models | |
parent | 76ad136b2a46e626f398872a71fa04fa4ad29743 (diff) | |
download | redmine-2a0257e8af822b1e3022479b213ca4bf7d0ef903.tar.gz redmine-2a0257e8af822b1e3022479b213ca4bf7d0ef903.zip |
Use open scope in version issues count methods.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8285 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/issue.rb | 5 | ||||
-rw-r--r-- | app/models/version.rb | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index be69d929f..199efe119 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -63,7 +63,10 @@ class Issue < ActiveRecord::Base named_scope :visible, lambda {|*args| { :include => :project, :conditions => Issue.visible_condition(args.shift || User.current, *args) } } - named_scope :open, :conditions => ["#{IssueStatus.table_name}.is_closed = ?", false], :include => :status + named_scope :open, lambda {|*args| + is_closed = args.size > 0 ? !args.first : false + {:conditions => ["#{IssueStatus.table_name}.is_closed = ?", is_closed], :include => :status} + } named_scope :recently_updated, :order => "#{Issue.table_name}.updated_on DESC" named_scope :with_limit, lambda { |limit| { :limit => limit} } diff --git a/app/models/version.rb b/app/models/version.rb index 3340be77e..8002ac9c8 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -124,12 +124,12 @@ class Version < ActiveRecord::Base # Returns the total amount of open issues for this version. def open_issues_count - @open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status) + @open_issues_count ||= Issue.open.count(:all, :conditions => ["fixed_version_id = ?", self.id]) end # Returns the total amount of closed issues for this version. def closed_issues_count - @closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status) + @closed_issues_count ||= Issue.open(false).count(:all, :conditions => ["fixed_version_id = ?", self.id]) end def wiki_page |