diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-27 22:13:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-11-27 22:13:14 +0000 |
commit | 9a270c46c0aa3fbfd799a38122b115878840e5d8 (patch) | |
tree | 0177ac9dd94dbb2129efdc87733fd3de5d5aede7 /app/models/version.rb | |
parent | e43448f6cae297b8364c0d0520daf8f0041649c7 (diff) | |
download | redmine-9a270c46c0aa3fbfd799a38122b115878840e5d8.tar.gz redmine-9a270c46c0aa3fbfd799a38122b115878840e5d8.zip |
Code cleanup.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10887 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/version.rb')
-rw-r--r-- | app/models/version.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/app/models/version.rb b/app/models/version.rb index 16db9f05c..212ce851d 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -35,10 +35,11 @@ class Version < ActiveRecord::Base validates_inclusion_of :sharing, :in => VERSION_SHARINGS validate :validate_version - scope :named, lambda {|arg| { :conditions => ["LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip]}} - scope :open, :conditions => {:status => 'open'} - scope :visible, lambda {|*args| { :include => :project, - :conditions => Project.allowed_to_condition(args.first || User.current, :view_issues) } } + scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)} + scope :open, where(:status => 'open') + scope :visible, lambda {|*args| + includes(:project).where(Project.allowed_to_condition(args.first || User.current, :view_issues)) + } safe_attributes 'name', 'description', @@ -79,7 +80,7 @@ class Version < ActiveRecord::Base # Returns the total reported time for this version def spent_hours - @spent_hours ||= TimeEntry.sum(:hours, :joins => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f + @spent_hours ||= TimeEntry.joins(:issue).where("#{Issue.table_name}.fixed_version_id = ?", id).sum(:hours).to_f end def closed? |