From 3dddffaa34e55a30113cca5f7a3678451d99dbf2 Mon Sep 17 00:00:00 2001 From: Luka Murn Date: Wed, 24 Aug 2016 17:22:16 +0200 Subject: [PATCH] Fix bug with linked tasks This bug was a legacy of experiment level introduction. Closes SCI-385, SCI-366. --- .../protocol_linked_children_datatable.rb | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/app/datatables/protocol_linked_children_datatable.rb b/app/datatables/protocol_linked_children_datatable.rb index 945539605..ad218ab0f 100644 --- a/app/datatables/protocol_linked_children_datatable.rb +++ b/app/datatables/protocol_linked_children_datatable.rb @@ -11,13 +11,13 @@ class ProtocolLinkedChildrenDatatable < AjaxDatatablesRails::Base def sortable_columns @sortable_columns ||= [ - "Protocol.id" + 'Protocol.id' ] end def sortable_displayed_columns @sortable_displayed_columns ||= [ - "0" + '0' ] end @@ -31,8 +31,8 @@ class ProtocolLinkedChildrenDatatable < AjaxDatatablesRails::Base def data records.map do |record| { - "DT_RowId": record.id, - "1": record_html(record) + 'DT_RowId' => record.id, + '1' => record_html(record) } end end @@ -42,33 +42,38 @@ class ProtocolLinkedChildrenDatatable < AjaxDatatablesRails::Base def get_raw_records records = Protocol - .joins(my_module: :project) - .includes(my_module: :project) - .references(my_module: :project) - .where(protocol_type: Protocol.protocol_types[:linked]) - .where(parent: @protocol) + .joins(my_module: { experiment: :project }) + .includes(my_module: { experiment: :project }) + .references(my_module: { experiment: :project }) + .where(protocol_type: Protocol.protocol_types[:linked]) + .where(parent: @protocol) records.distinct end # Helper methods def record_html(record) - res = "" + res = '' res += "" + res += '' + res += '' res end - end