Class: WorkCompletion::TubeCompletion

Inherits:
Object
  • Object
show all
Defined in:
app/models/work_completion/tube_completion.rb

Overview

Class WorkCompletion::PlateCompletion provides the business logic for passing plates, especially in the Limber pipelines. This has been pulled out of WorkCompletion itself to allow for separate behaviour for plates and tubes.

Author:

  • Genome Research Ltd.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tube, submission_ids) ⇒ TubeCompletion

Returns a new instance of TubeCompletion


13
14
15
16
# File 'app/models/work_completion/tube_completion.rb', line 13

def initialize(tube, submission_ids)
  @target_tube = tube
  @submission_ids = submission_ids
end

Instance Attribute Details

#submission_idsObject (readonly)

Returns the value of attribute submission_ids


11
12
13
# File 'app/models/work_completion/tube_completion.rb', line 11

def submission_ids
  @submission_ids
end

#target_tubeObject (readonly)

Returns the value of attribute target_tube


11
12
13
# File 'app/models/work_completion/tube_completion.rb', line 11

def target_tube
  @target_tube
end

Instance Method Details

#connect_requestsObject


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/work_completion/tube_completion.rb', line 22

def connect_requests
  # Upstream requests our on our stock wells.
  detect_upstream_requests.each do |upstream|
    # We need to find the downstream requests BEFORE connecting the upstream
    # This is because submission.next_requests tries to take a shortcut through
    # the target_asset if it is defined.
    upstream.next_requests.each { |ds| ds.update!(asset: target_tube) }
    # In some cases, such as the Illumina-C pipelines, requests might be
    # connected upfront. We don't want to touch these.
    upstream.target_asset ||= target_tube
    # We don't try and pass failed requests.
    # I'm not 100% convinced this decision belongs here, and instead
    # we may want to let the client specify wells to pass, and perform
    # validation to ensure this is correct. However this increases
    # the complexity of both the code and the interface, with only
    # marginal system simplification.
    upstream.pass if upstream.may_pass?
    upstream.save!
  end
end

#detect_upstream_requestsObject


43
44
45
46
# File 'app/models/work_completion/tube_completion.rb', line 43

def detect_upstream_requests
  CustomerRequest.includes(WorkCompletion::REQUEST_INCLUDES)
                 .where(id: target_tube.aliquots.pluck(:request_id))
end

#processObject


18
19
20
# File 'app/models/work_completion/tube_completion.rb', line 18

def process
  connect_requests
end