Class: PreCapturePool::Builder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(submission) ⇒ Builder

Returns a new instance of Builder


35
36
37
# File 'app/models/pre_capture_pool.rb', line 35

def initialize(submission)
  @submission = submission
end

Instance Attribute Details

#submissionObject (readonly)

Returns the value of attribute submission


33
34
35
# File 'app/models/pre_capture_pool.rb', line 33

def submission
  @submission
end

Instance Method Details

#build!Object


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/models/pre_capture_pool.rb', line 39

def build!
  ActiveRecord::Base.transaction do
    return unless poolable?

    # We find the library creation requests sorted in column order
    # and then walk downstream until we get to the poolable requests.
    # It is these requests that get assigned to a pre-capture pool.
    # We can't jump to the poolable requests directly, as they may not
    # be sorted in column order.
    grouped_requests.each do |_, requests|
      plex = requests.first.order.request_options['pre_capture_plex_level'].to_i
      poolable_requests = requests.flat_map do |request|
        walk_to_pooled_request(request)
      end
      pool(poolable_requests, plex)
    end
  end
end