Merge pull request #75 from NobodysNightmare/feature/replace_deprecated_finders

replace deprecated find(:all, ...) finders
pull/6827/head
Alex Coles 9 years ago
commit b73bd6b569
  1. 29
      app/controllers/cost_reports_controller.rb
  2. 2
      app/models/cost_query/filter/activity_id.rb
  3. 2
      app/models/cost_query/filter/cost_object_id.rb
  4. 2
      app/models/cost_query/filter/cost_type_id.rb
  5. 2
      app/models/cost_query/filter/priority_id.rb
  6. 2
      app/models/cost_query/filter/status_id.rb
  7. 2
      app/models/cost_query/filter/type_id.rb

@ -160,7 +160,7 @@ class CostReportsController < ApplicationController
# set the @cost_types -> this is used to determine which tabs to display # set the @cost_types -> this is used to determine which tabs to display
def set_active_cost_types def set_active_cost_types
unless session[:report] && (@cost_types = session[:report][:filters][:values][:cost_type_id].try(:collect, &:to_i)) unless session[:report] && (@cost_types = session[:report][:filters][:values][:cost_type_id].try(:collect, &:to_i))
relevant_cost_types = CostType.find(:all, select: 'id', order: 'id ASC').select do |t| relevant_cost_types = CostType.select(:id).order('id ASC').select do |t|
t.cost_entries.count > 0 t.cost_entries.count > 0
end.collect(&:id) end.collect(&:id)
@cost_types = [-1, 0, *relevant_cost_types] @cost_types = [-1, 0, *relevant_cost_types]
@ -222,29 +222,24 @@ class CostReportsController < ApplicationController
def public_queries def public_queries
if @project if @project
CostQuery.find(:all, CostQuery.where(['is_public = ? AND (project_id IS NULL OR project_id = ?)', true, @project])
conditions: ['is_public = ? AND (project_id IS NULL OR project_id = ?)', .order('name ASC')
true, @project],
order: 'name ASC')
else else
CostQuery.find(:all, CostQuery.where(['is_public = ? AND project_id IS NULL', true])
conditions: ['is_public = ? AND project_id IS NULL', .order('name ASC')
true],
order: 'name ASC')
end end
end end
def private_queries def private_queries
if @project if @project
CostQuery.find(:all, CostQuery.where(['user_id = ? AND is_public = ? AND (project_id IS NULL OR project_id = ?)',
conditions: ['user_id = ? AND is_public = ? AND (project_id IS NULL OR project_id = ?)', current_user,
current_user, false, @project], false,
order: 'name ASC') @project])
.order('name ASC')
else else
CostQuery.find(:all, CostQuery.where(['user_id = ? AND is_public = ? AND project_id IS NULL', current_user, false])
conditions: ['user_id = ? AND is_public = ? AND project_id IS NULL', .order('name ASC')
current_user, false],
order: 'name ASC')
end end
end end

@ -23,6 +23,6 @@ class CostQuery::Filter::ActivityId < Report::Filter::Base
end end
def self.available_values(*) def self.available_values(*)
TimeEntryActivity.find(:all, order: 'name').map { |a| [a.name, a.id] } TimeEntryActivity.order('name').pluck(:name, :id)
end end
end end

@ -26,6 +26,6 @@ class CostQuery::Filter::CostObjectId < Report::Filter::Base
end end
def self.available_values(*) def self.available_values(*)
([[l(:caption_labor), -1]] + CostObject.find(:all, order: 'name').map { |t| [t.name, t.id] }) [[l(:caption_labor), -1]] + CostObject.order('name').pluck(:name, :id)
end end
end end

@ -39,6 +39,6 @@ class CostQuery::Filter::CostTypeId < Report::Filter::Base
end end
def self.available_values(*) def self.available_values(*)
([[::I18n.t(:caption_labor), -1]] + CostType.find(:all, order: 'name').map { |t| [t.name, t.id] }) [[::I18n.t(:caption_labor), -1]] + CostType.order('name').pluck(:name, :id)
end end
end end

@ -26,6 +26,6 @@ class CostQuery::Filter::PriorityId < Report::Filter::Base
end end
def self.available_values(*) def self.available_values(*)
IssuePriority.find(:all, order: 'position DESC').map { |i| [i.name, i.id] } IssuePriority.order('position DESC').pluck(:name, :id)
end end
end end

@ -29,6 +29,6 @@ class CostQuery::Filter::StatusId < Report::Filter::Base
end end
def self.available_values(*) def self.available_values(*)
Status.find(:all, order: 'name').map { |i| [i.name, i.id] } Status.order('name').pluck(:name, :id)
end end
end end

@ -26,6 +26,6 @@ class CostQuery::Filter::TypeId < Report::Filter::Base
end end
def self.available_values(*) def self.available_values(*)
Type.find(:all, order: 'name').map { |i| [i.name, i.id] } Type.order('name').pluck(:name, :id)
end end
end end

Loading…
Cancel
Save