maintenance_tasks 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/maintenance_tasks/application_controller.rb +1 -2
- data/app/controllers/maintenance_tasks/runs_controller.rb +0 -1
- data/app/controllers/maintenance_tasks/tasks_controller.rb +0 -1
- data/app/helpers/maintenance_tasks/application_helper.rb +0 -1
- data/app/helpers/maintenance_tasks/{task_helper.rb → tasks_helper.rb} +1 -2
- data/app/jobs/maintenance_tasks/task_job.rb +19 -0
- data/app/models/maintenance_tasks/application_record.rb +2 -2
- data/app/models/maintenance_tasks/csv_collection.rb +0 -1
- data/app/models/maintenance_tasks/progress.rb +6 -3
- data/app/models/maintenance_tasks/run.rb +0 -1
- data/app/models/maintenance_tasks/task_data.rb +0 -1
- data/app/models/maintenance_tasks/ticker.rb +0 -1
- data/app/tasks/maintenance_tasks/task.rb +6 -3
- data/app/validators/maintenance_tasks/run_status_validator.rb +0 -1
- data/app/views/maintenance_tasks/runs/_info.html.erb +1 -0
- data/app/views/maintenance_tasks/runs/_run.html.erb +1 -6
- data/db/migrate/20210225152418_remove_index_on_task_name.rb +14 -0
- data/lib/generators/maintenance_tasks/install_generator.rb +0 -1
- data/lib/generators/maintenance_tasks/task_generator.rb +0 -1
- data/lib/maintenance_tasks.rb +4 -0
- data/lib/maintenance_tasks/cli.rb +0 -1
- data/lib/maintenance_tasks/engine.rb +4 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '017924f32ef1d9cb9e8ef6b739e1dc7ab60695dce1ee03c9f9f14fcaa35dfdde'
|
4
|
+
data.tar.gz: 17d3d2e220dd8b3cc7270797398abe33e5c90e38a3d19b28a571cb61c94a567c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0942f2e8f1d23e1dc180a13deef7af7c198dcb348fdd62ed0c9107d4eded0a7908c0477c6e15c954658f4a99a41c5858fec4b02477d8deed4f72f44c4ae7cb5e'
|
7
|
+
data.tar.gz: 61c1d448e4c1eaf7a8076dc253d72de1d515b70ed4623b76a290b24dd4e6f0c76aff6fccde27619eceffc497ca750910aa9590363f2c3cbd2085a75a8838a18f
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module MaintenanceTasks
|
4
4
|
# Base class for all controllers used by this engine.
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# Can be extended to add different authentication and authorization code.
|
7
7
|
class ApplicationController < ActionController::Base
|
8
8
|
include Pagy::Backend
|
9
9
|
|
@@ -22,5 +22,4 @@ module MaintenanceTasks
|
|
22
22
|
|
23
23
|
protect_from_forgery with: :exception
|
24
24
|
end
|
25
|
-
private_constant :ApplicationController
|
26
25
|
end
|
@@ -6,7 +6,7 @@ module MaintenanceTasks
|
|
6
6
|
# Helpers for formatting data in the maintenance_tasks views.
|
7
7
|
#
|
8
8
|
# @api private
|
9
|
-
module
|
9
|
+
module TasksHelper
|
10
10
|
STATUS_COLOURS = {
|
11
11
|
'new' => ['is-primary'],
|
12
12
|
'enqueued' => ['is-primary is-light'],
|
@@ -114,5 +114,4 @@ module MaintenanceTasks
|
|
114
114
|
)
|
115
115
|
end
|
116
116
|
end
|
117
|
-
private_constant :TaskHelper
|
118
117
|
end
|
@@ -97,8 +97,27 @@ module MaintenanceTasks
|
|
97
97
|
@ticker.persist
|
98
98
|
end
|
99
99
|
|
100
|
+
# We are reopening a private part of Job Iteration's API here, so we should
|
101
|
+
# ensure the method is still defined upstream. This way, in the case where
|
102
|
+
# the method changes upstream, we catch it at load time instead of at
|
103
|
+
# runtime while calling `super`.
|
104
|
+
unless private_method_defined?(:reenqueue_iteration_job)
|
105
|
+
error_message = <<~HEREDOC
|
106
|
+
JobIteration::Iteration#reenqueue_iteration_job is expected to be
|
107
|
+
defined. Upgrading the maintenance_tasks gem should solve this problem.
|
108
|
+
HEREDOC
|
109
|
+
raise error_message
|
110
|
+
end
|
111
|
+
def reenqueue_iteration_job(should_ignore: true)
|
112
|
+
super() unless should_ignore
|
113
|
+
@reenqueue_iteration_job = true
|
114
|
+
end
|
115
|
+
|
100
116
|
def after_perform
|
101
117
|
@run.save!
|
118
|
+
if defined?(@reenqueue_iteration_job) && @reenqueue_iteration_job
|
119
|
+
reenqueue_iteration_job(should_ignore: false)
|
120
|
+
end
|
102
121
|
end
|
103
122
|
|
104
123
|
def on_error(error)
|
@@ -2,9 +2,9 @@
|
|
2
2
|
module MaintenanceTasks
|
3
3
|
# Base class for all records used by this engine.
|
4
4
|
#
|
5
|
-
#
|
5
|
+
# Can be extended to setup different database where all tables related to
|
6
|
+
# maintenance tasks will live.
|
6
7
|
class ApplicationRecord < ActiveRecord::Base
|
7
8
|
self.abstract_class = true
|
8
9
|
end
|
9
|
-
private_constant :ApplicationRecord
|
10
10
|
end
|
@@ -49,7 +49,7 @@ module MaintenanceTasks
|
|
49
49
|
def title
|
50
50
|
if !total?
|
51
51
|
"Processed #{@run.tick_count} #{'item'.pluralize(@run.tick_count)}."
|
52
|
-
elsif
|
52
|
+
elsif over_total?
|
53
53
|
"Processed #{@run.tick_count} #{'item'.pluralize(@run.tick_count)} " \
|
54
54
|
"(expected #{@run.tick_total})."
|
55
55
|
else
|
@@ -67,8 +67,11 @@ module MaintenanceTasks
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def estimatable?
|
70
|
-
total? &&
|
70
|
+
total? && !over_total?
|
71
|
+
end
|
72
|
+
|
73
|
+
def over_total?
|
74
|
+
@run.tick_count > @run.tick_total
|
71
75
|
end
|
72
76
|
end
|
73
|
-
private_constant :Progress
|
74
77
|
end
|
@@ -16,9 +16,12 @@ module MaintenanceTasks
|
|
16
16
|
#
|
17
17
|
# @raise [NotFoundError] if a Task with the given name does not exist.
|
18
18
|
def named(name)
|
19
|
-
name.
|
20
|
-
|
21
|
-
|
19
|
+
task = name.safe_constantize
|
20
|
+
raise NotFoundError.new("Task #{name} not found.", name) unless task
|
21
|
+
unless task.is_a?(Class) && task < Task
|
22
|
+
raise NotFoundError.new("#{name} is not a Task.", name)
|
23
|
+
end
|
24
|
+
task
|
22
25
|
end
|
23
26
|
|
24
27
|
# Returns a list of concrete classes that inherit from the Task
|
@@ -1,8 +1,3 @@
|
|
1
1
|
<div class="box">
|
2
|
-
|
3
|
-
<%= time_tag run.created_at, title: run.created_at %>
|
4
|
-
<%= status_tag run.status %>
|
5
|
-
</h5>
|
6
|
-
|
7
|
-
<%= render 'maintenance_tasks/runs/info', run: run %>
|
2
|
+
<%= render 'maintenance_tasks/runs/info', run: run, with_status: true %>
|
8
3
|
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
class RemoveIndexOnTaskName < ActiveRecord::Migration[6.1]
|
3
|
+
def up
|
4
|
+
change_table(:maintenance_tasks_runs) do |t|
|
5
|
+
t.remove_index(:task_name)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
change_table(:maintenance_tasks_runs) do |t|
|
11
|
+
t.index(:task_name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/maintenance_tasks.rb
CHANGED
@@ -9,6 +9,10 @@ require 'maintenance_tasks/engine'
|
|
9
9
|
require 'pagy'
|
10
10
|
require 'pagy/extras/bulma'
|
11
11
|
|
12
|
+
# Force the TaskJob class to load so we can verify upstream compatibility with
|
13
|
+
# the JobIteration gem
|
14
|
+
require_relative '../app/jobs/maintenance_tasks/task_job'
|
15
|
+
|
12
16
|
# The engine's namespace module. It provides isolation between the host
|
13
17
|
# application's code and the engine-specific code. Top-level engine constants
|
14
18
|
# and variables are defined under this module.
|
@@ -7,6 +7,10 @@ module MaintenanceTasks
|
|
7
7
|
class Engine < ::Rails::Engine
|
8
8
|
isolate_namespace MaintenanceTasks
|
9
9
|
|
10
|
+
initializer 'eager_load_for_classic_autoloader' do
|
11
|
+
eager_load! unless Rails.autoloaders.zeitwerk_enabled?
|
12
|
+
end
|
13
|
+
|
10
14
|
config.to_prepare do
|
11
15
|
unless Rails.autoloaders.zeitwerk_enabled?
|
12
16
|
tasks_module = MaintenanceTasks.tasks_module.underscore
|
@@ -17,7 +21,6 @@ module MaintenanceTasks
|
|
17
21
|
end
|
18
22
|
|
19
23
|
config.after_initialize do
|
20
|
-
eager_load! unless Rails.autoloaders.zeitwerk_enabled?
|
21
24
|
JobIteration.max_job_runtime ||= 5.minutes
|
22
25
|
end
|
23
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maintenance_tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -107,7 +107,7 @@ files:
|
|
107
107
|
- app/controllers/maintenance_tasks/runs_controller.rb
|
108
108
|
- app/controllers/maintenance_tasks/tasks_controller.rb
|
109
109
|
- app/helpers/maintenance_tasks/application_helper.rb
|
110
|
-
- app/helpers/maintenance_tasks/
|
110
|
+
- app/helpers/maintenance_tasks/tasks_helper.rb
|
111
111
|
- app/jobs/maintenance_tasks/task_job.rb
|
112
112
|
- app/models/maintenance_tasks/application_record.rb
|
113
113
|
- app/models/maintenance_tasks/csv_collection.rb
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- app/views/maintenance_tasks/tasks/show.html.erb
|
137
137
|
- config/routes.rb
|
138
138
|
- db/migrate/20201211151756_create_maintenance_tasks_runs.rb
|
139
|
+
- db/migrate/20210225152418_remove_index_on_task_name.rb
|
139
140
|
- exe/maintenance_tasks
|
140
141
|
- lib/generators/maintenance_tasks/install_generator.rb
|
141
142
|
- lib/generators/maintenance_tasks/task_generator.rb
|
@@ -150,10 +151,10 @@ files:
|
|
150
151
|
homepage: https://github.com/Shopify/maintenance_tasks
|
151
152
|
licenses: []
|
152
153
|
metadata:
|
153
|
-
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.1.
|
154
|
+
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.1.1
|
154
155
|
allowed_push_host: https://rubygems.org
|
155
156
|
post_install_message: |-
|
156
|
-
Thank you for installing Maintenance Tasks 1.1.
|
157
|
+
Thank you for installing Maintenance Tasks 1.1.1. To complete, please run:
|
157
158
|
|
158
159
|
rails generate maintenance_tasks:install
|
159
160
|
rdoc_options: []
|