From f9ddb562d58ae98bcc69f74396b028cbc8cce0b1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Wed, 12 Jun 2013 19:13:25 +0000 Subject: Cleanup of finders with :conditions option. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11963 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/queries_helper.rb | 2 +- app/helpers/versions_helper.rb | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index 2de6b0c90..d92c300e1 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -185,7 +185,7 @@ module QueriesHelper if !params[:query_id].blank? cond = "project_id IS NULL" cond << " OR project_id = #{@project.id}" if @project - @query = IssueQuery.find(params[:query_id], :conditions => cond) + @query = IssueQuery.where(cond).find(params[:query_id]) raise ::Unauthorized unless @query.visible? @query.project = @project session[:query] = {:id => @query.id, :project_id => @query.project_id} diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 61cb382c5..082daabd3 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -35,12 +35,9 @@ module VersionsHelper h = Hash.new {|k,v| k[v] = [0, 0]} begin # Total issue count - Issue.count(:group => criteria, - :conditions => ["#{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s} + Issue.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][0] = s} # Open issues count - Issue.count(:group => criteria, - :include => :status, - :conditions => ["#{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s} + Issue.open.where(:fixed_version_id => version.id).group(criteria).count.each {|c,s| h[c][1] = s} rescue ActiveRecord::RecordNotFound # When grouping by an association, Rails throws this exception if there's no result (bug) end -- cgit v1.2.3