Class: SearchController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- SearchController
- Defined in:
- app/controllers/search_controller.rb
Overview
Handles most of the indexes of plates/tubes
Defined Under Namespace
Classes: InputError
Instance Method Summary collapse
-
#create ⇒ Object
rubocop:todo Metrics/AbcSize.
- #find_labware(barcode) ⇒ Object
- #find_qcable(barcode) ⇒ Object
- #new ⇒ Object
-
#ongoing_plates ⇒ Object
rubocop:todo Metrics/AbcSize.
-
#ongoing_tubes ⇒ Object
rubocop:todo Metrics/AbcSize.
- #qcables ⇒ Object
Instance Method Details
#create ⇒ Object
rubocop:todo Metrics/AbcSize
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/search_controller.rb', line 38 def create # rubocop:todo Metrics/AbcSize raise 'You have not supplied a labware barcode' if params[:plate_barcode].blank? respond_to { |format| format.html { redirect_to find_labware(params[:plate_barcode]) } } rescue StandardError => e flash.now[:error] = e. # rendering new without re-searching for the ongoing plates... respond_to do |format| format.html { render :new } format.json { render json: { error: e. }, status: :not_found } end end |
#find_labware(barcode) ⇒ Object
52 53 54 55 56 |
# File 'app/controllers/search_controller.rb', line 52 def find_labware() Sequencescape::Api::V2 .() .tap { |labware| raise "Sorry, could not find labware with the barcode '#{}'." if labware.nil? } end |
#find_qcable(barcode) ⇒ Object
58 59 60 61 62 |
# File 'app/controllers/search_controller.rb', line 58 def find_qcable() api.search.find(Settings.searches['Find qcable by barcode']).first(barcode: ) rescue Sequencescape::Api::ResourceNotFound => e raise e, "Sorry, could not find qcable with the barcode '#{}'." end |
#new ⇒ Object
10 |
# File 'app/controllers/search_controller.rb', line 10 def new; end |
#ongoing_plates ⇒ Object
rubocop:todo Metrics/AbcSize
12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/search_controller.rb', line 12 def ongoing_plates # rubocop:todo Metrics/AbcSize plate_search = api.search.find(Settings.searches.fetch('Find plates')) @purpose_options = helpers.('plate') @search_options = OngoingPlate.new(ongoing_plate_search_params) @search_options.page = params['page'].to_i if params['page'].present? @search_results = plate_search.all(Limber::Plate, @search_options.search_parameters) @search_options.total_results = @search_results.size end |
#ongoing_tubes ⇒ Object
rubocop:todo Metrics/AbcSize
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/search_controller.rb', line 22 def ongoing_tubes # rubocop:todo Metrics/AbcSize tube_search = api.search.find(Settings.searches.fetch('Find tubes')) @purpose_options = helpers.('tube') @search_options = OngoingTube.new(ongoing_tube_search_params) @search_options.page = params['page'].to_i if params['page'].present? @search_results = tube_search.all(Limber::Tube, @search_options.search_parameters) @search_options.total_results = @search_results.size end |
#qcables ⇒ Object
32 33 34 35 36 |
# File 'app/controllers/search_controller.rb', line 32 def qcables respond_to { |format| format.json { redirect_to find_qcable() } } rescue Sequencescape::Api::ResourceNotFound, ActionController::ParameterMissing, InputError => e render json: { 'error' => e. } end |