diff --git a/.gitignore b/.gitignore index a92e25d9..8486f4db 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ coverage # Ignore .talismanrc .talismanrc + +.idea diff --git a/.release-version b/.release-version index ff278344..622f042f 100644 --- a/.release-version +++ b/.release-version @@ -1 +1 @@ -1.17.5 +1.17.6 diff --git a/Gemfile.lock b/Gemfile.lock index 9ec6a32f..43613555 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,25 +7,25 @@ GIT GEM remote: https://rubygems.org/ specs: - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) - activesupport (7.0.8) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activesupport (7.0.8.1) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -42,7 +42,7 @@ GEM concurrent-ruby (1.2.3) connection_pool (2.2.5) crass (1.0.6) - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) erubi (1.12.0) factory_bot (6.4.5) @@ -71,9 +71,9 @@ GEM guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) hashie (5.0.0) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) - json (2.7.1) + json (2.7.2) language_server-protocol (3.17.0.3) listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) @@ -84,12 +84,12 @@ GEM lumberjack (1.2.9) method_source (1.0.0) mini_portile2 (2.8.5) - minitest (5.21.2) + minitest (5.22.3) msgpack (1.7.2) multi_json (1.15.0) mysql2 (0.5.6) nenv (0.3.0) - nokogiri (1.16.2) + nokogiri (1.16.3) mini_portile2 (~> 2.8.2) racc (~> 1.4) notiffany (0.1.3) @@ -103,7 +103,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) racc (1.7.3) - rack (2.2.8) + rack (2.2.9) rack-test (2.1.0) rack (>= 1.3) rails-dom-testing (2.2.0) @@ -113,9 +113,9 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) method_source rake (>= 12.2) thor (~> 1.0) @@ -128,28 +128,28 @@ GEM rbtree (0.4.4) regexp_parser (2.9.0) rexml (3.2.6) - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-mocks (3.12.6) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.1.1) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) - rspec-support (3.12.1) - rubocop (1.60.2) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) + rubocop (1.63.0) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) @@ -157,27 +157,30 @@ GEM rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.30.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) rubocop-capybara (2.20.0) rubocop (~> 1.41) - rubocop-factory_bot (2.25.0) - rubocop (~> 1.33) - rubocop-performance (1.20.2) + rubocop-factory_bot (2.25.1) + rubocop (~> 1.41) + rubocop-performance (1.21.0) rubocop (>= 1.48.1, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rails (2.23.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.24.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) - rubocop-ast (>= 1.30.0, < 2.0) - rubocop-rspec (2.26.1) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (2.29.1) rubocop (~> 1.40) rubocop-capybara (~> 2.17) rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.28.2) + rubocop (~> 1.40) ruby-progressbar (1.13.0) sanger_warren (0.4.1) bunny (~> 2.17) @@ -195,11 +198,11 @@ GEM sorted_set (1.0.3) rbtree set (~> 1.0) - thor (1.3.0) + thor (1.3.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS ruby diff --git a/app/models/aliquot.rb b/app/models/aliquot.rb new file mode 100644 index 00000000..6f7f9255 --- /dev/null +++ b/app/models/aliquot.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# Aliquot model +# This model is used to store aliquot data +class Aliquot < ApplicationRecord + include ResourceTools + include SingularResourceTools + + def self.base_resource_key + 'lims_uuid' + end + + json do + translate( + uuid: :lims_uuid + ) + end +end diff --git a/db/migrate/20240404142248_create_aliquots.rb b/db/migrate/20240404142248_create_aliquots.rb new file mode 100644 index 00000000..078bda47 --- /dev/null +++ b/db/migrate/20240404142248_create_aliquots.rb @@ -0,0 +1,24 @@ +class CreateAliquots < ActiveRecord::Migration[7.0] + def up + create_table :aliquot, primary_key: :id, options: 'CHARSET=utf8 COLLATE=utf8_unicode_ci' do |t| + t.string :id_lims, null: false, comment: 'The LIMS system that the aliquot was created in' + t.string :lims_uuid, null: false, comment: 'The UUID of the aliquot in the LIMS system' + t.string :aliquot_type, null: false, comment: 'The type of the aliquot' + t.string :source_type, null: false, comment: 'The type of the source of the aliquot' + t.string :source_barcode, null: false, comment: 'The barcode of the source of the aliquot' + t.string :sample_name, null: false, comment: 'The name of the sample that the aliquot was created from' + t.string :used_by_type, null: false, comment: 'The type of the entity that the aliquot is used by' + t.string :used_by_barcode, null: false, comment: 'The barcode of the entity that the aliquot is used by' + t.decimal :volume, precision: 10, scale: 2, null: false, comment: 'The volume of the aliquot (uL)' + t.decimal :concentration, precision: 10, scale: 2, comment: 'The concentration of the aliquot (ng/ul)' + t.datetime :created, null: false, comment: 'The date and time that the aliquot was created' + t.datetime :last_updated, null: false, comment: 'The date and time that the aliquot was last updated' + t.datetime :deleted_at, comment: 'The date and time that the aliquot was deleted' + t.datetime :recorded_at, comment: 'The date and time that the aliquot was recorded' + end + end + + def down + drop_table :aliquot + end +end diff --git a/db/schema.rb b/db/schema.rb index 280d2c1a..759f4c1a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,24 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2024_02_28_140011) do +ActiveRecord::Schema[7.0].define(version: 2024_04_04_142248) do + create_table "aliquot", charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t| + t.string "id_lims", null: false, comment: "The LIMS system that the aliquot was created in" + t.string "lims_uuid", null: false, comment: "The UUID of the aliquot in the LIMS system" + t.string "aliquot_type", null: false, comment: "The type of the aliquot" + t.string "source_type", null: false, comment: "The type of the source of the aliquot" + t.string "source_barcode", null: false, comment: "The barcode of the source of the aliquot" + t.string "sample_name", null: false, comment: "The name of the sample that the aliquot was created from" + t.string "used_by_type", null: false, comment: "The type of the entity that the aliquot is used by" + t.string "used_by_barcode", null: false, comment: "The barcode of the entity that the aliquot is used by" + t.decimal "volume", precision: 10, scale: 2, null: false, comment: "The volume of the aliquot (uL)" + t.decimal "concentration", precision: 10, scale: 2, comment: "The concentration of the aliquot (ng/ul)" + t.datetime "created", null: false, comment: "The date and time that the aliquot was created" + t.datetime "last_updated", null: false, comment: "The date and time that the aliquot was last updated" + t.datetime "deleted_at", comment: "The date and time that the aliquot was deleted" + t.datetime "recorded_at", comment: "The date and time that the aliquot was recorded" + end + create_table "bmap_flowcell", primary_key: "id_bmap_flowcell_tmp", id: :integer, charset: "utf8mb3", collation: "utf8mb3_unicode_ci", force: :cascade do |t| t.datetime "last_updated", precision: nil, null: false, comment: "Timestamp of last update" t.datetime "recorded_at", precision: nil, null: false, comment: "Timestamp of warehouse update" diff --git a/lib/resource_tools/json.rb b/lib/resource_tools/json.rb index 87d980dc..28f19040 100644 --- a/lib/resource_tools/json.rb +++ b/lib/resource_tools/json.rb @@ -146,7 +146,6 @@ def custom_value(name, &block) end end - # rubocop:disable Style/ArgumentsForwarding def initialize(*args, &block) super if self.class.custom_values.present? @@ -157,7 +156,6 @@ def initialize(*args, &block) convert_booleans delete_if { |k, _| ignoreable.include?(k) } end - # rubocop:enable Style/ArgumentsForwarding def convert_booleans self.stored_as_boolean.each do |key| diff --git a/spec/factories.rb b/spec/factories.rb index 4c6ab8ce..3174162c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -82,4 +82,20 @@ created_at { Time.new(2020, 4, 2, 1, 0, 0, '+00:00') } updated_at { Time.new(2020, 4, 2, 1, 0, 0, '+00:00') } end + + factory :aliquot do + sequence(:id) { |n| n } + id_lims { 'example' } + lims_uuid { '000000-0000-0000-0000-0000000002' } + aliquot_type { 'derivative' } + source_type { 'library' } + source_barcode { 'PR-rna-00000001_H12' } + sample_name { 'aliquot-sample' } + used_by_type { 'pool' } + used_by_barcode { 'pool-barcode' } + volume { 24.98589115 } + concentration { 12.46979445 } + created { Time.new(2012, 3, 11, 10, 20, 8, '+00:00') } + last_updated { Time.new(2012, 3, 11, 10, 20, 8, '+00:00') } + end end diff --git a/spec/models/aliquots_spec.rb b/spec/models/aliquots_spec.rb new file mode 100644 index 00000000..35d50c10 --- /dev/null +++ b/spec/models/aliquots_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Aliquot do + context 'aliquots' do + let(:json) do + { 'id_lims' => 'example', + 'aliquot_type' => 'DNA', + 'volume' => 5.43, + 'concentration' => 2.34, + 'lims_uuid' => '000000-0000-0000-0000-0000000002', + 'source_type' => 'library', + 'source_barcode' => 'PR-rna-00000001_H12', + 'sample_name' => 'aliquot-sample', + 'used_by_type' => 'pool', + 'used_by_barcode' => 'pool-barcode', + 'last_updated' => '2012-03-11 10:20:08', + 'created' => '2012-03-11 10:20:08' } + end + it_behaves_like 'a singular resource' + end +end