2018-09-14 01:42:05 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-05-16 07:41:15 -04:00
|
|
|
class Admin::JobsController < Admin::ApplicationController
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2015-12-04 06:55:23 -05:00
|
|
|
def index
|
|
|
|
@scope = params[:scope]
|
|
|
|
@all_builds = Ci::Build
|
2018-07-30 12:58:31 -04:00
|
|
|
@builds = @all_builds.order('id DESC')
|
2015-12-04 06:55:23 -05:00
|
|
|
@builds =
|
|
|
|
case @scope
|
2016-07-05 04:10:34 -04:00
|
|
|
when 'pending'
|
|
|
|
@builds.pending.reverse_order
|
2015-12-30 09:25:42 -05:00
|
|
|
when 'running'
|
2016-07-05 04:10:34 -04:00
|
|
|
@builds.running.reverse_order
|
2015-12-04 06:55:23 -05:00
|
|
|
when 'finished'
|
|
|
|
@builds.finished
|
|
|
|
else
|
2015-12-30 09:25:42 -05:00
|
|
|
@builds
|
2015-12-04 06:55:23 -05:00
|
|
|
end
|
|
|
|
@builds = @builds.page(params[:page]).per(30)
|
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2015-12-04 06:55:23 -05:00
|
|
|
|
|
|
|
def cancel_all
|
|
|
|
Ci::Build.running_or_pending.each(&:cancel)
|
|
|
|
|
2018-07-02 06:43:06 -04:00
|
|
|
redirect_to admin_jobs_path, status: :see_other
|
2015-12-04 06:55:23 -05:00
|
|
|
end
|
|
|
|
end
|