Module: Pipeline::InboxExtensions

Defined in:
app/models/pipeline/inbox_extensions.rb

Instance Method Summary collapse

Instance Method Details

#inbox(show_held_requests = true, current_page = 1, search_action = nil) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/pipeline/inbox_extensions.rb', line 2

def inbox(show_held_requests = true, current_page = 1, search_action = nil)
  requests = proxy_association.scope
  pipeline = proxy_association.owner
  # Build a list of methods to invoke to build the correct request list
  actions = [:unbatched]
  actions << ((pipeline.group_by_parent? or show_held_requests) ? :full_inbox : :pipeline_pending)
  actions << [(pipeline.group_by_parent? ? :asset_on_labware : :with_present_asset)]

  if search_action != :count
    actions << :include_request_metadata if pipeline.request_information_types.exists?
    actions << (pipeline.group_by_submission? ? :ordered_for_submission_grouped_inbox : :ordered_for_ungrouped_inbox)
    actions << pipeline.inbox_eager_loading
  end

  if search_action.present?
    actions << [search_action]
  elsif pipeline.paginate?
    actions << [:paginate, { per_page: 50, page: current_page }]
  end

  actions.inject(requests) { |context, action| context.send(*Array(action)) }
end

#inputs(show_held_requests = false) ⇒ Object

Used by the Pipeline class to retrieve the list of requests that are coming into the pipeline.


26
27
28
# File 'app/models/pipeline/inbox_extensions.rb', line 26

def inputs(show_held_requests = false)
  ready_in_storage.send(show_held_requests ? :full_inbox : :pipeline_pending)
end