diff --git a/app/models/checklist.rb b/app/models/checklist.rb index b865cd965..b5204f7b6 100644 --- a/app/models/checklist.rb +++ b/app/models/checklist.rb @@ -41,7 +41,7 @@ class Checklist < ApplicationRecord new_query = Checklist.distinct .where(checklists: { step_id: step_ids }) - .joins('LEFT JOIN checklist_items ON checklists.id = checklist_items.checklist_id') + .left_outer_joins(:checklist_items) .where_attributes_like(['checklists.name', 'checklist_items.text'], query, options) # Show all results if needed diff --git a/app/models/table.rb b/app/models/table.rb index 23e026934..130971ea5 100644 --- a/app/models/table.rb +++ b/app/models/table.rb @@ -46,9 +46,7 @@ class Table < ApplicationRecord .pluck('result_tables.id') table_query = Table.distinct - .joins('LEFT OUTER JOIN step_tables ON step_tables.table_id = tables.id') - .joins('LEFT OUTER JOIN result_tables ON result_tables.table_id = tables.id') - .joins('LEFT OUTER JOIN results ON result_tables.result_id = results.id') + .left_outer_joins(:step_table, :result_table, :result) .where('step_tables.id IN (?) OR result_tables.id IN (?)', step_ids, result_ids) if options[:whole_word].to_s == 'true' || diff --git a/app/models/user.rb b/app/models/user.rb index 425733486..2b135122d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -373,7 +373,7 @@ class User < ApplicationRecord if team_to_ignore.present? ignored_ids = UserTeam.select(:user_id).where(team_id: team_to_ignore.id) - result = result.where.not('users.id IN (?)', ignored_ids) + result = result.where.not(users: { id: ignored_ids }) end result.where_attributes_like(%i(full_name email), query).distinct