From f4bf2ab75fa9c36acc3e18af59e999b717bcdcc3 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Thu, 22 Oct 2020 14:29:35 +0200 Subject: [PATCH] Remove empty children from extents --- app/models/report.rb | 2 +- config/initializers/extends.rb | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/app/models/report.rb b/app/models/report.rb index 1686fa725..84556d095 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -116,7 +116,7 @@ class Report < ApplicationRecord 'type_of' => element[:type_of] || element[:type_of_lambda].call(object), 'id' => { element[:id_key] => object.id }, 'sort_order' => element[:sort_order], - 'children' => gen_element_content(object, element[:children]) + 'children' => gen_element_content(object, element[:children] || []) } hash_object['id'][element[:parent_id_key]] = parent.id if element[:parent_id_key] hash_object diff --git a/config/initializers/extends.rb b/config/initializers/extends.rb index 15519fc2a..025d54ef8 100644 --- a/config/initializers/extends.rb +++ b/config/initializers/extends.rb @@ -45,7 +45,6 @@ class Extends { type_of: 'project_header', id_key: 'project_id', - children: [] }, { type_of: 'experiment', @@ -60,7 +59,6 @@ class Extends { type_of: 'my_module_protocol', id_key: 'my_module_id', - children: [] }, { type_of: 'step', @@ -71,25 +69,21 @@ class Extends type_of: 'step_asset', relation: %w(assets), id_key: 'asset_id', - children: [] }, { type_of: 'step_table', relation: %w(tables), id_key: 'table_id', - children: [] }, { type_of: 'step_checklist', relation: %w(checklists), id_key: 'checklist_id', - children: [] }, { type_of: 'step_comments', id_key: 'step_id', sort_order: 'asc', - children: [] } ] }, @@ -104,23 +98,20 @@ class Extends children: [{ type_of: 'result_comments', id_key: 'result_id', - sort_order: 'asc', - children: [] + sort_order: 'asc' }] }, { type_of: 'my_module_activity', id_key: 'my_module_id', - sort_order: 'asc', - children: [] + sort_order: 'asc' }, { type_of: 'my_module_repository', relation: %w(experiment project assigned_repositories_and_snapshots), id_key: 'repository_id', parent_id_key: 'my_module_id', - sort_order: 'asc', - children: [] + sort_order: 'asc' } ] }