Module: Submission::AssetSubmissionFinder
- Included in:
- BulkSubmission
- Defined in:
- app/models/submission/asset_submission_finder.rb
Instance Method Summary collapse
- #find_all_assets_by_name_including_samples!(names) ⇒ Object
-
#find_tubes_including_samples_for!(details) ⇒ Object
rubocop:enable Metrics/MethodLength.
-
#find_wells_including_samples_for!(details) ⇒ Object
rubocop:todo Metrics/MethodLength.
- #is_plate?(details) ⇒ Boolean
- #is_tube?(details) ⇒ Boolean
Instance Method Details
#find_all_assets_by_name_including_samples!(names) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'app/models/submission/asset_submission_finder.rb', line 11 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
rubocop:enable Metrics/MethodLength
40 41 42 43 44 45 46 47 48 49 |
# File 'app/models/submission/asset_submission_finder.rb', line 40 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
rubocop:todo Metrics/MethodLength
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/models/submission/asset_submission_finder.rb', line 22 def find_wells_including_samples_for!(details) # rubocop:todo Metrics/AbcSize , 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
3 4 5 |
# File 'app/models/submission/asset_submission_finder.rb', line 3 def is_plate?(details) details['barcode'].present? && details['plate well'].present? end |
#is_tube?(details) ⇒ Boolean
7 8 9 |
# File 'app/models/submission/asset_submission_finder.rb', line 7 def is_tube?(details) details['barcode'].present? && details['plate well'].blank? end |