Module: Labimotion::Helpers::DatasetHelpers
- Extended by:
- Grape::API::Helpers
- Defined in:
- lib/labimotion/helpers/dataset_helpers.rb
Overview
ElementHelpers
Instance Method Summary collapse
Instance Method Details
#create_repo_klass(params) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/labimotion/helpers/dataset_helpers.rb', line 30 def create_repo_klass(params) response = Labimotion::Libs::TemplateHub.fetch_identifier('Dataset', params[:identifier]) attributes = response.slice('ols_term_id', 'label', 'desc', 'uuid', 'identifier') # .except(:id, :is_active, :place, :created_by, :created_at, :updated_at) attributes['properties_template'] = response['properties_release'] attributes['place'] = ((DatasetKlass.all.length * 10) || 0) + 10 attributes['updated_by'] = current_user.id attributes['sync_by'] = current_user.id attributes['sync_time'] = DateTime.now if DatasetKlass.find_by(ols_term_id: attributes['ols_term_id']).present? ds = DatasetKlass.find_by(ols_term_id: attributes['ols_term_id']) ds.update!(attributes) else attributes['created_by'] = current_user.id DatasetKlass.create!(attributes) end end |
#fetch_repo ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/labimotion/helpers/dataset_helpers.rb', line 19 def fetch_repo ds_klasses = DatasetKlass.where.not(identifier: nil)&.pluck(:identifier) || [] response = Labimotion::Libs::TemplateHub.list('Dataset') if response && response['list'].present? && response['list'].length.positive? filter_list = response['list']&.reject do |ds| ds_klasses.include?(ds['identifier']) end || [] end filter_list || [] end |
#klass_list(is_active) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/labimotion/helpers/dataset_helpers.rb', line 11 def klass_list(is_active) if is_active == true DatasetKlass.where(is_active: true).order('place') || [] else DatasetKlass.all.order('place') || [] end end |