Class: PlateSummariesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/plate_summaries_controller.rb

Constant Summary

Constants included from FlashTruncation

FlashTruncation::STRING_OVERHEAD

Instance Method Summary collapse

Methods inherited from ApplicationController

#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!

Methods included from FlashTruncation

#max_flash_size, #truncate_flash, #truncate_flash_array

Instance Method Details

#indexObject



5
6
7
# File 'app/controllers/plate_summaries_controller.rb', line 5

def index
  @plates = Plate.source_plates.with_descendants_owned_by(current_user).order(id: :desc).page(params[:page])
end

#searchObject

rubocop:todo Metrics/AbcSize



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/plate_summaries_controller.rb', line 17

def search # rubocop:todo Metrics/AbcSize
  candidate_plate = Plate.find_from_any_barcode(params[:plate_barcode])
  @barcode = params[:plate_barcode]
  @plates = candidate_plate&.source_plates

  if @plates.blank?
    redirect_back fallback_location: root_path,
                  flash: {
                    error: "No suitable plates found for barcode #{params[:plate_barcode]}"
                  }
  elsif @plates.one?
    redirect_to plate_summary_path(@plates.first.human_barcode)
  else
    render :search
  end
end

#showObject



9
10
11
12
13
14
15
# File 'app/controllers/plate_summaries_controller.rb', line 9

def show
  @plate = Plate.find_from_any_barcode(params[:id])
  raise ActiveRecord::RecordNotFound if @plate.nil?

  @custom_metadatum_collection = @plate.custom_metadatum_collection || NullCustomMetadatumCollection.new
  @sequencing_batches = @plate.descendant_lanes.include_creation_batches.map(&:creation_batches).flatten.uniq
end