Class: Labimotion::DatasetKlass
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Labimotion::DatasetKlass
- Includes:
- GenericKlass, GenericKlassRevisions
- Defined in:
- lib/labimotion/models/dataset_klass.rb
Class Method Summary collapse
Methods included from GenericKlassRevisions
#check_identifier, #create_klasses_revision
Class Method Details
.init_seeds ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/labimotion/models/dataset_klass.rb', line 21 def self.init_seeds gem_spec = Gem.loaded_specs['labimotion'] gem_root = gem_spec.gem_dir if gem_spec seeds_path = File.join(gem_root, 'db', 'seeds', 'dataset_klasses.json') seeds = JSON.parse(File.read(seeds_path)) seeds['chmo'].each do |term| next if Labimotion::DatasetKlass.where(ols_term_id: term['id']).count.positive? attributes = { ols_term_id: term['id'], label: "#{term['label']} (#{term['synonym']})", desc: "#{term['label']} (#{term['synonym']})", place: term['position'], created_by: Admin.first&.id || 0 } Labimotion::DatasetKlass.create!(attributes) end true end |