Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Y24-372 - Correct country of origin values for submissions #4433

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/models/accessionable/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions db/migrate/20241018131928_disable_invalid_insdc_countries.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/accession/accession/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
Loading