Class: AddSpikedInControlTask

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

Overview

A Task used in the sequencing pipelines. Associates a tube of SpikedBuffer with a Lane indicating that PhiX has been added to the lane in question.

Defined Under Namespace

Classes: SpikedBufferRecord

Instance Method Summary collapse

Methods inherited from Task

#can_link_directly?, #included_for_do_task, #included_for_render_task, #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

#can_process?(batch) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/add_spiked_in_control_task.rb', line 28

def can_process?(batch)
  batch.released? ? [true, 'Edit'] : [true, nil]
end

#do_task(workflows_controller, params, user) ⇒ Object



32
33
34
35
36
37
38
39
# File 'app/models/add_spiked_in_control_task.rb', line 32

def do_task(workflows_controller, params, user)
  Tasks::AddSpikedInControlHandler::Handler.new(
    controller: workflows_controller,
    params: params,
    task: self,
    user: user
  ).perform
end

#fields_for(requests) ⇒ Object



41
42
43
44
45
46
47
# File 'app/models/add_spiked_in_control_task.rb', line 41

def fields_for(requests)
  if per_item_for(requests)
    requests.map { |request| phi_x_for(request.lane, request) }
  else
    phi_x_for(requests.first.lane, nil)
  end
end

#partialObject



24
25
26
# File 'app/models/add_spiked_in_control_task.rb', line 24

def partial
  'add_spiked_in_control'
end

#per_item_for(requests) ⇒ Object

Returns true if we should collect descriptors per request. Always true if #per_item is true, otherwise true if requests have different values



52
53
54
# File 'app/models/add_spiked_in_control_task.rb', line 52

def per_item_for(requests)
  per_item || requests.map { |request| phi_x_for(request.lane, nil) }.uniq.many?
end

#phi_x_for(lane, request) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'app/models/add_spiked_in_control_task.rb', line 56

def phi_x_for(lane, request)
  if lane.direct_spiked_in_buffer
    SpikedBufferRecord.new(lane.direct_spiked_in_buffer.machine_barcode, false, request)
  elsif lane.most_recent_spiked_in_buffer
    SpikedBufferRecord.new(lane.most_recent_spiked_in_buffer.machine_barcode, true, request)
  else
    SpikedBufferRecord.new(nil, false, request)
  end
end