aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-21 20:40:59 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-21 20:40:59 +0100
commitda1926efc1e1f150f27e0c93d1461e3f1eb8c85a (patch)
treeba043a349e337113f2754642a9b78b020b547762 /app
parent7dbc313632ecebd638bd464bdc430292218d4c9e (diff)
downloadgovuk-mini-environment-admin-da1926efc1e1f150f27e0c93d1461e3f1eb8c85a.tar
govuk-mini-environment-admin-da1926efc1e1f150f27e0c93d1461e3f1eb8c85a.tar.gz
Update Que to 1.0.0 (beta 3)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/que_jobs_controller.rb8
-rw-r--r--app/models/que_job.rb24
-rw-r--r--app/views/shared/_jobs.html.erb4
3 files changed, 20 insertions, 16 deletions
diff --git a/app/controllers/que_jobs_controller.rb b/app/controllers/que_jobs_controller.rb
index a458e9d..36d5558 100644
--- a/app/controllers/que_jobs_controller.rb
+++ b/app/controllers/que_jobs_controller.rb
@@ -20,9 +20,7 @@
class QueJobsController < ApplicationController
def cancel
- ActiveRecord::Base.connection.execute(
- "DELETE FROM que_jobs WHERE job_id = #{job_id}::bigint"
- )
+ Que.execute :expire_job, [job_id]
flash[:success] = 'Job canceled'
@@ -32,8 +30,8 @@ class QueJobsController < ApplicationController
def retry_now
ActiveRecord::Base.connection.execute(
"UPDATE que_jobs
- SET run_at = now()
- WHERE job_id = #{job_id}::bigint"
+ SET run_at = now()
+ WHERE id = #{job_id}::bigint"
)
flash[:success] = 'Retrying the job now'
diff --git a/app/models/que_job.rb b/app/models/que_job.rb
index a2227b8..4bddaa0 100644
--- a/app/models/que_job.rb
+++ b/app/models/que_job.rb
@@ -22,15 +22,21 @@
#
# Table name: que_jobs
#
-# priority :integer default(100), not null
-# run_at :datetime not null
-# job_id :integer not null
-# job_class :text not null
-# args :json not null
-# error_count :integer default(0), not null
-# last_error :text
-# queue :text default(""), not null
+# priority :integer default(100), not null
+# run_at :datetime not null
+# id :integer not null, primary key
+# job_class :text not null
+# error_count :integer default(0), not null
+# last_error_message :text
+# queue :text default("default"), not null
+# last_error_backtrace :text
+# finished_at :datetime
+# expired_at :datetime
+# args :jsonb not null
+# data :jsonb not null
#
-class QueJob < ActiveRecord::Base
+require 'que/active_record/model'
+
+class QueJob < Que::ActiveRecord::Model
end
diff --git a/app/views/shared/_jobs.html.erb b/app/views/shared/_jobs.html.erb
index a151389..73d59ce 100644
--- a/app/views/shared/_jobs.html.erb
+++ b/app/views/shared/_jobs.html.erb
@@ -42,13 +42,13 @@
<pre><%= job['last_error'] %></pre>
</div>
<div class="col-md-2">
- <%= form_with(url: retry_now_que_job_path(job['job_id'])) do %>
+ <%= form_with(url: retry_now_que_job_path(job.id)) do %>
<%= submit_tag(
'Retry now',
class: 'btn btn-primary btn-lg btn-block'
) %>
<% end %>
- <%= form_with(url: cancel_que_job_path(job['job_id'])) do %>
+ <%= form_with(url: cancel_que_job_path(job.id)) do %>
<%= submit_tag(
'Cancel Job',
class: 'btn btn-warning btn-lg btn-block',