diff --git a/app/models/accessionable/base.rb b/app/models/accessionable/base.rb index 16afd5819e..0093d815ca 100644 --- a/app/models/accessionable/base.rb +++ b/app/models/accessionable/base.rb @@ -95,6 +95,8 @@ class FieldSerializer MISSING_DATA_AGGREEMENT_PRE2023 = 'missing: data agreement established pre-2023' MISSING_ENDANGERED_SPECIES = 'missing: endangered species' MISSING_HUMAN_IDENTIFIABLE = 'missing: human-identifiable' + MISSING_CONTROL_SAMPLE = 'missing: control sample' + MISSING_SAMPLE_GROUP = 'missing: sample group' OTHER_DEFAULT_SETTINGS = [ NOT_COLLECTED, @@ -107,7 +109,9 @@ class FieldSerializer MISING_THIRD_PARTY_DATA, MISSING_DATA_AGGREEMENT_PRE2023, MISSING_ENDANGERED_SPECIES, - MISSING_HUMAN_IDENTIFIABLE + MISSING_HUMAN_IDENTIFIABLE, + MISSING_CONTROL_SAMPLE, + MISSING_SAMPLE_GROUP ].freeze def value_for(value) diff --git a/db/migrate/20241018131928_disable_invalid_insdc_countries.rb b/db/migrate/20241018131928_disable_invalid_insdc_countries.rb new file mode 100644 index 0000000000..143c3ed69b --- /dev/null +++ b/db/migrate/20241018131928_disable_invalid_insdc_countries.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +# This migration corrects the country list for missing samples/sample groups +# following EBI's checklist https://www.ebi.ac.uk/ena/browser/view/ERC000011 +class DisableInvalidInsdcCountries < ActiveRecord::Migration[6.1] + def change + # Disable existing invalid countries + # We don't want to delete them yet in case they are used in existing records and existing manifests. + ['not applicable: control sample', 'not applicable: sample group'].each do |name| + Insdc::Country.find_by(name:)&.invalid! + end + + # Add missing countries + ['missing: control sample', 'missing: sample group'].each do |name| + Insdc::Country.find_or_create_by(name: name, sort_priority: -2, validation_state: 0) + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 2f924b36c3..940e4e5f29 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2024_09_17_133813) do +ActiveRecord::Schema.define(version: 2024_10_18_131928) do create_table "aliquot_indices", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", options: "ENGINE=InnoDB ROW_FORMAT=DYNAMIC", force: :cascade do |t| t.integer "aliquot_id", null: false diff --git a/lib/accession/accession/tag.rb b/lib/accession/accession/tag.rb index 72d48842cd..4339051347 100644 --- a/lib/accession/accession/tag.rb +++ b/lib/accession/accession/tag.rb @@ -72,6 +72,8 @@ module HelperTagValue MISSING_DATA_AGGREEMENT_PRE2023 = 'missing: data agreement established pre-2023' MISSING_ENDANGERED_SPECIES = 'missing: endangered species' MISSING_HUMAN_IDENTIFIABLE = 'missing: human-identifiable' + MISSING_CONTROL_SAMPLE = 'missing: control sample' + MISSING_SAMPLE_GROUP = 'missing: sample group' OTHER_DEFAULT_SETTINGS = [ NOT_COLLECTED, @@ -84,7 +86,9 @@ module HelperTagValue MISING_THIRD_PARTY_DATA, MISSING_DATA_AGGREEMENT_PRE2023, MISSING_ENDANGERED_SPECIES, - MISSING_HUMAN_IDENTIFIABLE + MISSING_HUMAN_IDENTIFIABLE, + MISSING_CONTROL_SAMPLE, + MISSING_SAMPLE_GROUP ].freeze def incorrect_format_value