Class: GroundControl::Inertia::BulkDiscardsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ground_control/inertia/bulk_discards_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/ground_control/inertia/bulk_discards_controller.rb', line 6

def create
  jobs = ActiveJob.jobs.where(**@job_filters).failed

  if active_filters?
    count = [jobs.count, 3000].min
    jobs.limit(3000).discard_all
  else
    count = jobs.count
    jobs.discard_all
  end

  redirect_to ground_control_inertia.jobs_path(status: :failed), notice: "Discarded #{count} jobs"
end