From fd8187370e654a10ecc556464e9b462bc0b7f6f8 Mon Sep 17 00:00:00 2001 From: zmagod Date: Wed, 3 Aug 2016 13:16:51 +0200 Subject: [PATCH] Feed the Hound part 3 --- app/datatables/sample_datatable.rb | 39 ++++++++++++------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/app/datatables/sample_datatable.rb b/app/datatables/sample_datatable.rb index 717137084..fcbd27fe1 100644 --- a/app/datatables/sample_datatable.rb +++ b/app/datatables/sample_datatable.rb @@ -125,38 +125,29 @@ class SampleDatatable < AjaxDatatablesRails::Base if @my_module @assigned_samples = @my_module.samples - samples = samples - .joins( - "LEFT OUTER JOIN sample_my_modules ON - (samples.id = sample_my_modules.sample_id AND - (sample_my_modules.my_module_id = #{@my_module.id.to_s} OR - sample_my_modules.id IS NULL))" - ) - .references(:sample_my_modules) + samples = samples.joins("LEFT OUTER JOIN sample_my_modules ON + (samples.id = sample_my_modules.sample_id AND + (sample_my_modules.my_module_id = #{@my_module.id.to_s} OR + sample_my_modules.id IS NULL))") + .references(:sample_my_modules) elsif @project @assigned_samples = @project.assigned_samples ids = @project.my_modules_ids - samples = samples - .joins( - "LEFT OUTER JOIN sample_my_modules ON - (samples.id = sample_my_modules.sample_id AND - (sample_my_modules.my_module_id IN (#{ids}) OR - sample_my_modules.id IS NULL))" - ) - .references(:sample_my_modules) + samples = samples.joins("LEFT OUTER JOIN sample_my_modules ON + (samples.id = sample_my_modules.sample_id AND + (sample_my_modules.my_module_id IN (#{ids}) OR + sample_my_modules.id IS NULL))") + .references(:sample_my_modules) elsif @experiment @assigned_samples = @experiment.assigned_samples ids = @experiment.my_modules.select(:id) - samples = samples - .joins( - "LEFT OUTER JOIN sample_my_modules ON - (samples.id = sample_my_modules.sample_id AND - (sample_my_modules.my_module_id IN (#{ids.to_sql}) OR - sample_my_modules.id IS NULL))" - ) - .references(:sample_my_modules) + samples = samples.joins("LEFT OUTER JOIN sample_my_modules ON + (samples.id = sample_my_modules.sample_id AND + (sample_my_modules.my_module_id IN (#{ids.to_sql}) OR + sample_my_modules.id IS NULL))") + .references(:sample_my_modules) end # Make mappings of custom fields, so we have same id for every column