Class: PlateTemplateTask

Inherits:
Task show all
Defined in:
app/models/plate_template_task.rb

Overview

Handles display of plate template options (first page of cherrypicking) and the processing of any uploaded spreadsheets to set a layout

Direct Known Subclasses

FluidigmTemplateTask

Defined Under Namespace

Classes: SpreadsheetReader

Instance Method Summary collapse

Methods inherited from Task

#can_link_directly?, #can_process?, #included_for_do_task, #included_for_render_task

Methods inherited from ApplicationRecord

alias_association, convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Squishify

extended

Instance Method Details

#do_task(workflows_controller, params, _user) ⇒ Object

rubocop:todo Metrics/AbcSize



83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/models/plate_template_task.rb', line 83

def do_task(workflows_controller, params, _user) # rubocop:todo Metrics/AbcSize
  return true if params[:file].blank?

  plate_size =
    if params[:plate_template].blank?
      PlatePurpose.find(params[:plate_purpose_id]).size
    else
      PlateTemplate.find(params[:plate_template]['0'].to_i).size
    end
  workflows_controller.spreadsheet_layout =
    SpreadsheetReader.new(params[:file].read, workflows_controller.batch, plate_size).layout
  true
end

#partialObject



64
65
66
# File 'app/models/plate_template_task.rb', line 64

def partial
  'plate_template_batches'
end

#plate_purpose_options(batch) ⇒ Object

Returns a list of valid plate purpose types based on the requests in the current batch.



69
70
71
72
73
74
75
76
# File 'app/models/plate_template_task.rb', line 69

def plate_purpose_options(batch)
  requests = batch.requests.flat_map(&:next_requests)
  plate_purposes = requests.filter_map(&:request_type).uniq.map(&:acceptable_purposes).flatten.uniq

  # Fallback situation for the moment
  plate_purposes = PlatePurpose.cherrypickable_as_target.all if plate_purposes.empty?
  plate_purposes.map { |p| [p.name, p.size, p.id] }.sort
end

#render_task(workflows_controller, params, _user) ⇒ Object



78
79
80
81
# File 'app/models/plate_template_task.rb', line 78

def render_task(workflows_controller, params, _user)
  super
  workflows_controller.render_plate_template_task(self, params)
end