aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2018-06-21 23:07:02 +0100
committerChristopher Baines <mail@cbaines.net>2018-06-21 23:07:02 +0100
commitd20ab544d75cf504abefae7a2611958bf07103f4 (patch)
treeec8ead1f3b0d60f8a9b1f56aa9408bdaf1a26d88 /app
parent7ae6a547c0bd87aa884080dc239e6392051d50f6 (diff)
downloadgovuk-mini-environment-admin-d20ab544d75cf504abefae7a2611958bf07103f4.tar
govuk-mini-environment-admin-d20ab544d75cf504abefae7a2611958bf07103f4.tar.gz
Remove FinishedTerraformJob
This is no longer necessary, as Que now supports keeping the job entries around in the que_jobs table.
Diffstat (limited to 'app')
-rw-r--r--app/jobs/backends/deploy_terraform_libvirt_job.rb33
-rw-r--r--app/jobs/mini_environment_job.rb35
-rw-r--r--app/models/finished_terraform_job.rb34
-rw-r--r--app/models/mini_environment.rb9
4 files changed, 14 insertions, 97 deletions
diff --git a/app/jobs/backends/deploy_terraform_libvirt_job.rb b/app/jobs/backends/deploy_terraform_libvirt_job.rb
index 3b8b51a..4565189 100644
--- a/app/jobs/backends/deploy_terraform_libvirt_job.rb
+++ b/app/jobs/backends/deploy_terraform_libvirt_job.rb
@@ -27,33 +27,12 @@ class Backends::DeployTerraformLibvirtJob < Que::Job
.deploy_backend
end
- def destroy
- FinishedTerraformJob.create(
- model_id: @terraform_libvirt_backend_id,
- job_class: attrs[:job_class]
- )
- super
- end
-
def self.jobs(terraform_libvirt_backend_id)
- [
- QueJob
- .where(
- job_class: name
- ).where(
- "args->>0 = '#{terraform_libvirt_backend_id}'"
- ).to_a,
- FinishedTerraformJob
- .where(
- job_class: name,
- model_id: terraform_libvirt_backend_id
- )
- ].flatten.sort_by do |x|
- if x.instance_of? QueJob
- x.run_at
- else # FinishedTerraformJob
- x.created_at
- end
- end
+ QueJob
+ .where(
+ job_class: name
+ ).where(
+ "args->>0 = '#{terraform_libvirt_backend_id}'"
+ ).to_a
end
end
diff --git a/app/jobs/mini_environment_job.rb b/app/jobs/mini_environment_job.rb
index 90fbbd4..e5112cd 100644
--- a/app/jobs/mini_environment_job.rb
+++ b/app/jobs/mini_environment_job.rb
@@ -24,36 +24,17 @@ class MiniEnvironmentJob < Que::Job
@mini_environment = MiniEnvironment.find(mini_environment_id)
@mini_environment.backend.send(action, @mini_environment)
- end
- end
- def destroy
- FinishedTerraformJob.create(
- model_id: @mini_environment.id,
- job_class: attrs[:job_class]
- )
- super
+ finish
+ end
end
def self.jobs(mini_environment_id)
- [
- QueJob
- .where(
- job_class: name
- ).where(
- "args->>0 = '#{mini_environment_id}'"
- ).to_a,
- FinishedTerraformJob
- .where(
- job_class: name,
- model_id: mini_environment_id
- )
- ].flatten.sort_by do |x|
- if x.instance_of? QueJob
- x.run_at
- else # FinishedTerraformJob
- x.created_at
- end
- end
+ QueJob
+ .where(
+ job_class: name
+ ).where(
+ "args->>0 = '#{mini_environment_id}'"
+ ).to_a
end
end
diff --git a/app/models/finished_terraform_job.rb b/app/models/finished_terraform_job.rb
deleted file mode 100644
index ca2cb94..0000000
--- a/app/models/finished_terraform_job.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# GOV.UK Mini Environment Admin
-# Copyright © 2018 Christopher Baines <mail@cbaines.net>
-#
-# This file is part of the GOV.UK Mini Environment Admin.
-#
-# The GOV.UK Mini Environment Admin is free software: you can
-# redistribute it and/or modify it under the terms of the GNU Affero
-# General Public License as published by the Free Software Foundation,
-# either version 3 of the License, or (at your option) any later
-# version.
-#
-# The GOV.UK Mini Environment Admin is distributed in the hope that it
-# will be useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with the GOV.UK Mini Environment Admin. If not, see
-# <http://www.gnu.org/licenses/>.
-
-# == Schema Information
-#
-# Table name: finished_terraform_jobs
-#
-# id :integer not null, primary key
-# model_id :integer
-# job_class :string
-# created_at :datetime not null
-# updated_at :datetime not null
-#
-
-class FinishedTerraformJob < ApplicationRecord
- belongs_to :mini_environment
-end
diff --git a/app/models/mini_environment.rb b/app/models/mini_environment.rb
index 502cff2..d3f8ec3 100644
--- a/app/models/mini_environment.rb
+++ b/app/models/mini_environment.rb
@@ -36,15 +36,6 @@
#
class MiniEnvironment < ApplicationRecord
- has_many(
- :finished_terraform_jobs,
- lambda do |mini_environment|
- unscope(:where).where(
- 'finished_terraform_jobs.model_id = ?', mini_environment.id
- )
- end,
- dependent: :destroy
- )
belongs_to :govuk_guix_revision, class_name: 'GovukGuix::Revision'
belongs_to :backend, polymorphic: true