Class: IlluminaHtp::PooledPlatePurpose

Inherits:
PlatePurpose
  • Object
show all
Defined in:
app/models/illumina_htp/pooled_plate_purpose.rb

Instance Method Summary collapse

Instance Method Details

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


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/models/illumina_htp/pooled_plate_purpose.rb', line 2

def transition_to(plate, state, user, contents = nil, customer_accepts_responsibility = false)
  ActiveRecord::Base.transaction do
    super
    if (state == 'passed')
      plate.wells.with_aliquots.include_stock_wells.uniq.each do |well|
        # As we've already loaded the requests along with the stock wells, the ruby way is about 4 times faster
        library_creation_request = well.stock_wells.first.requests.detect { |r| r.library_creation? }
        requests = library_creation_request.submission.next_requests_via_submission(library_creation_request)
        requests.reject { |r| r.asset.present? }.slice(0, 12).each do |r|
          r.update!(asset: well)
        end
      end
    end
  end
end