Class: Ductwork::ApplicationController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Ductwork::ApplicationController
show all
- Defined in:
- app/controllers/ductwork/application_controller.rb
Constant Summary
collapse
- DEFAULT_PER_PAGE =
50
Instance Method Summary
collapse
Instance Method Details
#filter_by_klass(relation) ⇒ Object
16
17
18
19
20
21
22
|
# File 'app/controllers/ductwork/application_controller.rb', line 16
def filter_by_klass(relation)
if params[:klass].present?
relation.where(pipeline_klass: params[:klass])
else
relation
end
end
|
#filter_by_status(relation) ⇒ Object
24
25
26
27
28
29
30
|
# File 'app/controllers/ductwork/application_controller.rb', line 24
def filter_by_status(relation)
if params[:status].present?
relation.where(status: params[:status])
else
relation
end
end
|
#paginate(relation) ⇒ Object
32
33
34
35
36
37
|
# File 'app/controllers/ductwork/application_controller.rb', line 32
def paginate(relation)
per_page = @per_page || DEFAULT_PER_PAGE
offset = params[:page].to_i * per_page
relation.limit(per_page).offset(offset)
end
|
#query_pipeline_runs ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'app/controllers/ductwork/application_controller.rb', line 7
def query_pipeline_runs
Ductwork::Run
.includes(steps: { job: { executions: :result } })
.then(&method(:filter_by_klass))
.then(&method(:filter_by_status))
.then(&method(:paginate))
.order(started_at: :desc)
end
|