Module: Tasks::SamplePrepQcHandler

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

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#do_sample_prep_qc_task(task, params) ⇒ Object

rubocop:todo Metrics/MethodLength


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

def do_sample_prep_qc_task(task, params) # rubocop:todo Metrics/AbcSize
  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
    case qc_status
    when 'failed'
      request.fail!
    when '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


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

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