aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/que_jobs_controller.rb
blob: 34ac2011ebbb51b1162a339bada6102552fc5555 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class QueJobsController < ApplicationController
  def cancel
    ActiveRecord::Base.connection.execute(
      "DELETE FROM que_jobs WHERE job_id = #{job_id}::bigint"
    )

    flash[:success] = 'Job canceled'

    redirect_to mini_environments_path
  end

  def retry_now
    ActiveRecord::Base.connection.execute(
      "UPDATE que_jobs
       SET run_at      = now()
       WHERE job_id    = #{job_id}::bigint"
    )

    flash[:success] = 'Retrying the job now'

    redirect_to mini_environments_path
  end

  def job_id
    params[:id].to_i
  end
end