Module: CsvParserClient
- Included in:
- SampleManifestExcel::Upload::Processor::TubeRack
- Defined in:
- lib/csv_parser_client.rb
Overview
For communicating with the csv-parser microservice (github.com/sanger/csv-parser)
Class Method Summary collapse
-
.get_tube_rack_scan_results(tube_rack_barcode, object_to_add_errors_to) ⇒ Object
rubocop:todo Metrics/MethodLength.
- .no_read?(value_to_check) ⇒ Boolean
-
.remove_no_read_results(tube_barcode_to_coordinate) ⇒ Object
rubocop:enable Metrics/MethodLength.
Class Method Details
.get_tube_rack_scan_results(tube_rack_barcode, object_to_add_errors_to) ⇒ Object
rubocop:todo Metrics/MethodLength
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/csv_parser_client.rb', line 8 def self.get_tube_rack_scan_results(, object_to_add_errors_to) # rubocop:todo Metrics/AbcSize endpoint = configatron.tube_rack_scans_microservice_url response = Net::HTTP.get_response(URI(endpoint + )) if response.body.nil? = # rubocop:todo Layout/LineLength "Scan could not be retrieved for tube rack with barcode #{}. Service responded with status code #{response.code}" # rubocop:enable Layout/LineLength += " and message #{response.}." object_to_add_errors_to.errors.add(:base, ) return nil end begin scan_results = JSON.parse(response.body) rescue JSON::JSONError => e = # rubocop:todo Layout/LineLength "Response when trying to retrieve scan (tube rack with barcode #{}) was not valid JSON so could not be understood. Error message: #{e.}" # rubocop:enable Layout/LineLength object_to_add_errors_to.errors.add(:base, ) return nil end unless response.code == '200' = # rubocop:todo Layout/LineLength "Scan could not be retrieved for tube rack with barcode #{}. Service responded with status code #{response.code}" # rubocop:enable Layout/LineLength += " and the following message: #{scan_results['error']}" object_to_add_errors_to.errors.add(:base, ) return nil end return nil unless scan_results.key?('layout') = remove_no_read_results(scan_results['layout']) || nil end |
.no_read?(value_to_check) ⇒ Boolean
58 59 60 61 62 |
# File 'lib/csv_parser_client.rb', line 58 def self.no_read?(value_to_check) return true if value_to_check.casecmp('no read').zero? false end |
.remove_no_read_results(tube_barcode_to_coordinate) ⇒ Object
rubocop:enable Metrics/MethodLength
53 54 55 56 |
# File 'lib/csv_parser_client.rb', line 53 def self.remove_no_read_results() &.reject! { |key| no_read?(key) } unless .nil? # rubocop:todo Style/SafeNavigation end |