Class: GroundControl::Api::BulkDiscardsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ground_control/api/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/api/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

  render json: { message: "Discarded #{count} jobs" }
end