Class: PipelinesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PipelinesController
- Defined in:
- app/controllers/pipelines_controller.rb
Overview
The pipelines controller is concerned with pipelines lab processes that handle the processing of requests. This controller is concerned with those piplines that are handled internally by Sequencescape directly, not those processed by apps such as Limber. In general we have been trying to move this behaviour out of Sequencescape, but some legacy pipelines remain. = Endpoints Some of these endpoints should probably be moved elsewhere == CRUD - Showing a list of available pipelines to the users (index) - Displaying the Pipeline inbox to users, from which they can create batches (show) == Extra - Activation and deactivation of the pipeline (activate/deactivate) I'm not aware of any links to this - Listing batches associated with a pipeline (batches) [Move to Pipelines::Batches?] == Move to RequestsController? - Change the priority of a request via clicking the flag in the inbox (Update priority) == Move to BatchesController? The batches controller is already very large, but these definitely don't belong here - Finish a batch (finish) - Release a batch (release) - Show a batch summary (summary)
Constant Summary
Constants included from FlashTruncation
FlashTruncation::STRING_OVERHEAD
Instance Method Summary collapse
- #activate ⇒ Object
- #batches ⇒ Object
- #deactivate ⇒ Object
- #finish ⇒ Object
- #index ⇒ Object
- #release ⇒ Object
-
#show ⇒ Object
rubocop:todo Metrics/MethodLength.
-
#summary ⇒ Object
Renders the batch summary.
-
#update_priority ⇒ Object
to modify when next_request will be ready.
Methods inherited from ApplicationController
#block_api_access, #evil_parameter_hack!, #extract_header_info, #set_cache_disabled!
Methods included from FlashTruncation
#max_flash_size, #truncate_flash, #truncate_flash_array
Instance Method Details
#activate ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'app/controllers/pipelines_controller.rb', line 101 def activate @pipeline.active = true if @pipeline.save flash[:notice] = 'Pipeline activated' redirect_to pipelines_path else flash[:notice] = 'Failed to activate pipeline' redirect_to pipeline_path(@pipeline) end end |
#batches ⇒ Object
123 124 125 |
# File 'app/controllers/pipelines_controller.rb', line 123 def batches @batches = @pipeline.batches.order(id: :desc).page(params[:page]) end |
#deactivate ⇒ Object
112 113 114 115 116 117 118 119 120 121 |
# File 'app/controllers/pipelines_controller.rb', line 112 def deactivate @pipeline.active = false if @pipeline.save flash[:notice] = 'Pipeline deactivated' redirect_to pipelines_path else flash[:notice] = 'Failed to deactivate pipeline' redirect_to pipeline_path(@pipeline) end end |
#finish ⇒ Object
84 85 86 87 88 89 |
# File 'app/controllers/pipelines_controller.rb', line 84 def finish ActiveRecord::Base.transaction { @batch.complete!(current_user) } rescue ActiveRecord::RecordInvalid => e flash[:error] = e.record.errors. redirect_to(url_for(controller: 'batches', action: 'show', id: @batch.id)) end |
#index ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/pipelines_controller.rb', line 31 def index @pipelines = Pipeline.active.internally_managed.alphabetical @grouping = @pipelines.group_by(&:group_name) respond_to do |format| format.html format.xml { render xml: @pipelines.to_xml } end end |
#release ⇒ Object
91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/pipelines_controller.rb', line 91 def release ActiveRecord::Base.transaction do @batch = Batch.find(params[:id]) @batch.release!(current_user) end flash[:notice] = 'Batch released!' redirect_to controller: 'batches', action: 'show', id: @batch.id end |
#show ⇒ Object
rubocop:todo Metrics/MethodLength
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/controllers/pipelines_controller.rb', line 42 def show # rubocop:todo Metrics/AbcSize expires_now @show_held_requests = (params[:view] == 'all') @page_name = @pipeline.name @pending_batches = @pipeline.batches.pending_for_ui.includes_for_ui @batches_in_progress = @pipeline.batches.in_progress_for_ui.includes_for_ui @completed_batches = @pipeline.batches.completed_for_ui.includes_for_ui @released_batches = @pipeline.batches.released_for_ui.includes_for_ui @failed_batches = @pipeline.batches.failed_for_ui.includes_for_ui @batches = @last5_batches = @pipeline.batches.latest_first.includes_for_ui @information_types = @pipeline.request_information_types.shown_in_inbox if @pipeline.group_by_parent? Rails.logger.info('Pipeline grouped by parent') # We use the inbox presenter @inbox_presenter = Presenters::GroupedPipelineInboxPresenter.new(@pipeline, current_user, @show_held_requests) @requests_waiting = @inbox_presenter.requests_waiting else Rails.logger.info('Pipeline fallback behaviour') @requests_waiting = @pipeline.request_count_in_inbox(@show_held_requests) @requests = @pipeline.requests_in_inbox(@show_held_requests).to_a # We convert to an array here as otherwise rails tries to be smart and use # the scope in subsequent queries. Not only does it fail, but we may as # well fetch the result now anyway. @requests_comment_count = Comment.counts_for_requests(@requests) @requests_samples_count = Request.where(id: @requests).joins(:samples).group(:id).count end end |
#summary ⇒ Object
More out of the pipelines controller
Renders the batch summary
81 82 |
# File 'app/controllers/pipelines_controller.rb', line 81 def summary end |
#update_priority ⇒ Object
to modify when next_request will be ready
128 129 130 131 132 133 134 135 136 |
# File 'app/controllers/pipelines_controller.rb', line 128 def update_priority request = Request.find(params[:request_id]) ActiveRecord::Base.transaction do request.update_priority render plain: '', layout: false end rescue ActiveRecord::RecordInvalid => e render plain: '', layout: false, status: :unprocessable_entity end |