Module: Tasks::SamplePrepQcHandler

Included in:
WorkflowsController
Defined in:
app/models/tasks/sample_prep_qc_handler.rb

Instance Method Summary collapse

Instance Method Details

#do_sample_prep_qc_task(task, params) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/models/tasks/sample_prep_qc_handler.rb', line 6

def do_sample_prep_qc_task(task, params)
  requests = task.find_batch_requests(params[:batch_id])

  params[:request].each do |request_id, qc_status|
    requests_found = requests.select { |request| request.id == request_id.to_i }
    request = requests_found.first
    if request.nil?
      flash[:error] = "Couldnt find Request #{request_id}"
      return false
    end
    if qc_status == 'failed'
      request.fail!
    elsif qc_status == 'passed'
      request.pass!
      request.target_asset.labware..update!(smrt_cells_available: 1)
    else
      flash[:error] = "Invalid QC state for #{request_id}"
      return false
    end
  end

  true
end

#render_sample_prep_qc_task(task, params) ⇒ Object


2
3
4
# File 'app/models/tasks/sample_prep_qc_handler.rb', line 2

def render_sample_prep_qc_task(task, params)
  @requests = task.find_batch_requests(params[:batch_id])
end