builds_controller.rb 581 Bytes
Newer Older
1 2 3 4 5 6 7
class Admin::BuildsController < Admin::ApplicationController
  def index
    @scope = params[:scope]
    @all_builds = Ci::Build
    @builds = @all_builds.order('created_at DESC')
    @builds =
      case @scope
8 9
      when 'pending'
        @builds.pending.reverse_order
10
      when 'running'
11
        @builds.running.reverse_order
12 13 14
      when 'finished'
        @builds.finished
      else
15
        @builds
16 17 18 19 20 21 22 23 24 25
      end
    @builds = @builds.page(params[:page]).per(30)
  end

  def cancel_all
    Ci::Build.running_or_pending.each(&:cancel)

    redirect_to admin_builds_path
  end
end