Skip to content

Commit

Permalink
Fix for_type function in AssayClass
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Jan 17, 2024
1 parent 4415fe2 commit 60f9148
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 20 deletions.
8 changes: 4 additions & 4 deletions app/controllers/isa_assays_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class IsaAssaysController < ApplicationController

def new
if params[:is_assay_stream]
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.find_by(key: 'ASS').id } })
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.for_type('assay_stream').id } })
else
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.find_by(key: 'EXP').id } })
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.for_type('experimental').id } })
end
end

Expand Down Expand Up @@ -141,9 +141,9 @@ def set_up_instance_variable

def find_requested_item
if params[:is_assay_stream]
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.find_by(key: 'ASS').id } })
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.for_type('assay_stream').id } })
else
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.find_by(key: 'EXP').id } })
@isa_assay = IsaAssay.new({ assay: { assay_class_id: AssayClass.for_type('experimental').id } })
end
@isa_assay.populate(params[:id])

Expand Down
6 changes: 3 additions & 3 deletions app/models/assay_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class AssayClass < ApplicationRecord
# this returns an instance of AssayClass according to one of the types "experimental", "modelling" or "assay_stream"
# if there is not a match nil is returned
def self.for_type(type)
keys = { "experimental": 'EXP', "modelling": 'MODEL', 'assay_stream': 'ASS' }
AssayClass.find_by(key: keys[type])
keys = { "experimental": 'EXP', "modelling": 'MODEL', "assay_stream": 'ASS' }
AssayClass.find_by(key: keys[type.to_sym])
end

def self.experimental
Expand All @@ -15,7 +15,7 @@ def self.modelling
end

def self.assay_stream
for_type('assay_stream')
for_type('assaystream')
end

def is_modelling?
Expand Down
4 changes: 2 additions & 2 deletions app/views/isa_assays/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
if @isa_assay.assay.new_record?
if params[:is_assay_stream]
assay_position = 0
assay_class_id = AssayClass.find_by(key: 'ASS')&.id
assay_class_id = AssayClass.for_type('assay_stream').id
is_assay_stream = true
else
assay_position = params[:source_assay_id].nil? ? 1 : source_assay.position + 1
assay_class_id = AssayClass.find_by(key: 'EXP')&.id
assay_class_id = AssayClass.for_type('experimental').id
is_assay_stream = false
end
else
Expand Down
7 changes: 6 additions & 1 deletion config/default_data/assay_classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ experimental_assay_class:
modelling_assay_class:
id: 2
title: <%= I18n.t('assays.modelling_analysis') %>
key: MODEL
key: MODEL

assay_stream_class:
id: 3
title: <%= I18n.t('assays.assay_stream') %>
key: ASS
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ en:
assay: "Assay"
experimental_assay: "Experimental assay"
modelling_analysis: "Modelling analysis"
assay_stream: "Assay Stream"

isa_study: "ISA Study"
study_design: "Study Design"
Expand Down
7 changes: 0 additions & 7 deletions db/seeds/017_minimal_starter_isa_templates.seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,3 @@
end

puts 'Seeded minimal templates for organizing ISA JSON compliant experiments.'

disable_authorization_checks do
AssayClass.find_or_create_by(title: 'Assay Stream', key: 'ASS',
description: 'Special type of class that is user in Single Page, specifying this is a container for a stream of assays')
end

puts 'Seeded Extra Assay Class'
2 changes: 1 addition & 1 deletion lib/tasks/seek_upgrades.rake
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace :seek do
rename_registered_sample_multiple_attribute_type
remove_ontology_attribute_type
db:seed:007_sample_attribute_types
db:seed:017_minimal_starter_isa_templates
db:seed:001_create_controlled_vocabs
recognise_isa_json_compliant_items
]

Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/assay_classes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ modelling_assay_class:
key: MODEL

assay_stream_class:
title: 'Assay Stream'
key: 'ASS'
title: <%= I18n.t('assays.assay_stream') %>
key: ASS

0 comments on commit 60f9148

Please sign in to comment.