From 27d2ceacf233e748ab026a19fd61541dc2afb580 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Sat, 29 Aug 2015 21:31:34 +0200 Subject: [PATCH] Migrate remaining scopes to use lambda/block Signed-off-by: Alex Coles --- app/models/labor_budget_item.rb | 5 ++--- lib/open_project/costs/patches/time_entry_patch.rb | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/models/labor_budget_item.rb b/app/models/labor_budget_item.rb index ca94a2498f..1aee14fb85 100644 --- a/app/models/labor_budget_item.rb +++ b/app/models/labor_budget_item.rb @@ -40,9 +40,8 @@ class LaborBudgetItem < ActiveRecord::Base end scope :visible_costs, lambda{|*args| - { include: [{ cost_object: :project }, :user], - conditions: LaborBudgetItem.visible_condition((args.first || User.current), args[1]) - } + includes([{ cost_object: :project }, :user]) + .where(LaborBudgetItem.visible_condition((args.first || User.current), args[1])) } def costs diff --git a/lib/open_project/costs/patches/time_entry_patch.rb b/lib/open_project/costs/patches/time_entry_patch.rb index 2220e30604..cae29dbd0f 100644 --- a/lib/open_project/costs/patches/time_entry_patch.rb +++ b/lib/open_project/costs/patches/time_entry_patch.rb @@ -50,9 +50,8 @@ module OpenProject::Costs::Patches::TimeEntryPatch (#{Project.allowed_to_condition(user, :view_own_hourly_rate, project: project)} AND #{TimeEntry.table_name}.user_id = #{user.id})) } view_time_entries = TimeEntry.visible_condition(user, project) - { include: [:project, :user], - conditions: [view_time_entries, view_hourly_rates].join(' AND ') - } + includes(:project, :user) + .where([view_time_entries, view_hourly_rates].join(' AND ')) } end end