Class: Pulldown::InitialPlatePurpose

Inherits:
PlatePurpose
  • Object
show all
Defined in:
app/models/pulldown/initial_plate_purpose.rb

Overview

Specialised implementation of the plate purpose for the initial plate types in the Pulldown pipelines: WGS Covaris, SC Covaris, ISC Covaris.

Instance Method Summary collapse

Instance Method Details

#outer_requests(plate, contents) ⇒ Object


15
16
17
18
19
20
# File 'app/models/pulldown/initial_plate_purpose.rb', line 15

def outer_requests(plate, contents)
  well_ids = contents.present? ? plate.wells.located_at(contents).pluck(:id) : plate.wells.pluck(:id)
  Request.select('requests.*')
         .joins('INNER JOIN transfer_requests ON transfer_requests.asset_id = requests.asset_id')
         .where(transfer_requests: { target_asset_id: well_ids })
end

#transition_to(plate, state, user, contents = nil, customer_accepts_responsibility = false) ⇒ Object


4
5
6
7
8
9
10
11
12
13
# File 'app/models/pulldown/initial_plate_purpose.rb', line 4

def transition_to(plate, state, user, contents = nil, customer_accepts_responsibility = false)
  ActiveRecord::Base.transaction do
    super
    new_outer_state = %w[started passed qc_complete].include?(state) ? 'started' : state
    outer_requests(plate, contents).each do |request|
      # request.customer_accepts_responsibility! if customer_accepts_responsibility
      request.transition_to(new_outer_state) if request.pending?
    end
  end
end