Module: Submission::AssetSubmissionFinder
- Included in:
- BulkSubmission
- Defined in:
- app/models/submission/asset_submission_finder.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
- #find_all_assets_by_name_including_samples!(names) ⇒ Object
- #find_tubes_including_samples_for!(details) ⇒ Object
- #find_wells_including_samples_for!(details) ⇒ Object
- #is_plate?(details) ⇒ Boolean
- #is_tube?(details) ⇒ Boolean
Instance Method Details
#find_all_assets_by_name_including_samples!(names) ⇒ Object
10 11 12 13 14 15 |
# File 'app/models/submission/asset_submission_finder.rb', line 10 def find_all_assets_by_name_including_samples!(names) Receptacle.for_bulk_submission.named(names).tap do |found| missing = names - found.map(&:name) raise ActiveRecord::RecordNotFound, "Could not find Labware with names #{missing.inspect}" if missing.present? end end |
#find_tubes_including_samples_for!(details) ⇒ Object
33 34 35 36 37 38 |
# File 'app/models/submission/asset_submission_finder.rb', line 33 def find_tubes_including_samples_for!(details) Receptacle.on_a(Tube).for_bulk_submission.(details['barcode']).tap do |found| missing = details['barcode'].reject { || found.any? { |tube| tube.() } } raise ActiveRecord::RecordNotFound, "Could not find Tubes with barcodes #{missing.inspect}" if missing.present? end end |
#find_wells_including_samples_for!(details) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/submission/asset_submission_finder.rb', line 17 def find_wells_including_samples_for!(details) , well_list = details['barcode'], details['plate well'] errors.add(:spreadsheet, 'You can only specify one plate per asset group') unless .uniq.one? = .first plate = Plate.() raise StandardError, "Cannot find plate with barcode #{} for #{details['rows']}" if plate.nil? well_locations = well_list.map(&:strip) wells = plate.wells.for_bulk_submission.located_at(well_locations) if wells.length != well_locations.size raise StandardError, "Too few wells found for #{details['rows']}: #{wells.map(&:map).map(&:description).inspect}" end wells end |
#is_plate?(details) ⇒ Boolean
2 3 4 |
# File 'app/models/submission/asset_submission_finder.rb', line 2 def is_plate?(details) details['barcode'].present? && details['plate well'].present? end |
#is_tube?(details) ⇒ Boolean
6 7 8 |
# File 'app/models/submission/asset_submission_finder.rb', line 6 def is_tube?(details) details['barcode'].present? && details['plate well'].blank? end |