maintenance_tasks 1.9.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -17
- data/app/controllers/maintenance_tasks/application_controller.rb +9 -1
- data/app/controllers/maintenance_tasks/tasks_controller.rb +1 -1
- data/app/models/maintenance_tasks/batch_csv_collection_builder.rb +2 -1
- data/app/views/layouts/maintenance_tasks/application.html.erb +27 -9
- data/db/migrate/20220706101937_change_runs_tick_columns_to_bigints.rb +17 -0
- data/lib/generators/maintenance_tasks/templates/no_collection_task_test.rb.tt +1 -1
- data/lib/generators/maintenance_tasks/templates/task_spec.rb.tt +2 -2
- data/lib/generators/maintenance_tasks/templates/task_test.rb.tt +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8035a01cd9e715fec1b276b2f1c609266daeca88fa13d49ee1e2993370103f87
|
4
|
+
data.tar.gz: b6ec7e053b256aa725cd3c23f932fe35b480b2398667cdc2ba9e72b3059ca614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49aa01470360b4cde07fe1ce1d6a47158924fe0acca500ca21237374244c23a63560f4ea3fa03ec3f0dfae1ae8bb211817999b79c3057f1486f1c46ac75faab6
|
7
|
+
data.tar.gz: 85ac09e52d9396e83254fd1f0451e6627542a7fed4238397960b14b4c14112f71dc7f51600a8f650331bc9f74192e98e962537bb472021903e5a7fd93dfcec02
|
data/README.md
CHANGED
@@ -8,9 +8,9 @@ A Rails engine for queuing and managing maintenance tasks.
|
|
8
8
|
|
9
9
|
To install the gem and run the install generator, execute:
|
10
10
|
|
11
|
-
```
|
12
|
-
|
13
|
-
|
11
|
+
```sh-session
|
12
|
+
bundle add maintenance_tasks
|
13
|
+
bin/rails generate maintenance_tasks:install
|
14
14
|
```
|
15
15
|
|
16
16
|
The generator creates and runs a migration to add the necessary table to your
|
@@ -39,8 +39,8 @@ take a look at the [Active Job documentation][active-job-docs].
|
|
39
39
|
|
40
40
|
A generator is provided to create tasks. Generate a new task by running:
|
41
41
|
|
42
|
-
```
|
43
|
-
|
42
|
+
```sh-session
|
43
|
+
bin/rails generate maintenance_tasks:task update_posts
|
44
44
|
```
|
45
45
|
|
46
46
|
This creates the task file `app/tasks/maintenance/update_posts_task.rb`.
|
@@ -86,8 +86,8 @@ instuctions][setup].
|
|
86
86
|
|
87
87
|
Generate a CSV Task by running:
|
88
88
|
|
89
|
-
```
|
90
|
-
|
89
|
+
```sh-session
|
90
|
+
bin/rails generate maintenance_tasks:task import_posts --csv
|
91
91
|
```
|
92
92
|
|
93
93
|
The generated task is a subclass of `MaintenanceTasks::Task` that implements:
|
@@ -195,8 +195,8 @@ collection-less tasks.
|
|
195
195
|
|
196
196
|
Generate a collection-less Task by running:
|
197
197
|
|
198
|
-
```
|
199
|
-
|
198
|
+
```sh-session
|
199
|
+
bin/rails generate maintenance_tasks:task no_collection_task --no-collection
|
200
200
|
```
|
201
201
|
|
202
202
|
The generated task is a subclass of `MaintenanceTasks::Task` that implements:
|
@@ -483,21 +483,21 @@ You can run your new Task by accessing the Web UI and clicking on "Run".
|
|
483
483
|
|
484
484
|
Alternatively, you can run your Task in the command line:
|
485
485
|
|
486
|
-
```
|
487
|
-
|
486
|
+
```sh-session
|
487
|
+
bundle exec maintenance_tasks perform Maintenance::UpdatePostsTask
|
488
488
|
```
|
489
489
|
|
490
490
|
To run a Task that processes CSVs from the command line, use the --csv option:
|
491
491
|
|
492
|
-
```
|
493
|
-
|
492
|
+
```sh-session
|
493
|
+
bundle exec maintenance_tasks perform Maintenance::ImportPostsTask --csv "path/to/my_csv.csv"
|
494
494
|
```
|
495
495
|
|
496
496
|
To run a Task that takes arguments from the command line, use the --arguments
|
497
497
|
option, passing arguments as a set of \<key>:\<value> pairs:
|
498
498
|
|
499
|
-
```
|
500
|
-
|
499
|
+
```sh-session
|
500
|
+
bundle exec maintenance_tasks perform Maintenance::ParamsTask \
|
501
501
|
--arguments post_ids:1,2,3 content:"Hello, World!"
|
502
502
|
```
|
503
503
|
|
@@ -745,8 +745,8 @@ clean backtraces.
|
|
745
745
|
Use bundler to check for and upgrade to newer versions. After installing a new
|
746
746
|
version, re-run the install command:
|
747
747
|
|
748
|
-
```
|
749
|
-
|
748
|
+
```sh-session
|
749
|
+
bin/rails generate maintenance_tasks:install
|
750
750
|
```
|
751
751
|
|
752
752
|
This ensures that new migrations are installed and run as well.
|
@@ -8,7 +8,15 @@ module MaintenanceTasks
|
|
8
8
|
BULMA_CDN = "https://cdn.jsdelivr.net"
|
9
9
|
|
10
10
|
content_security_policy do |policy|
|
11
|
-
policy.style_src(
|
11
|
+
policy.style_src(
|
12
|
+
BULMA_CDN,
|
13
|
+
# ruby syntax highlighting
|
14
|
+
"'sha256-y9V0na/WU44EUNI/HDP7kZ7mfEci4PAOIjYOOan6JMA='",
|
15
|
+
)
|
16
|
+
policy.script_src(
|
17
|
+
# page refresh script
|
18
|
+
"'sha256-2RPaBS4XCMLp0JJ/sW407W9l4qjC+WQAHmTOFJTGfqo='",
|
19
|
+
)
|
12
20
|
policy.frame_ancestors(:self)
|
13
21
|
end
|
14
22
|
|
@@ -33,7 +33,8 @@ module MaintenanceTasks
|
|
33
33
|
#
|
34
34
|
# @return [Integer] the approximate number of batches to process.
|
35
35
|
def count(task)
|
36
|
-
|
36
|
+
count = task.csv_content.count("\n") - 1
|
37
|
+
(count + @batch_size - 1) / @batch_size
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
@@ -15,13 +15,13 @@
|
|
15
15
|
<%= csrf_meta_tags %>
|
16
16
|
|
17
17
|
<%=
|
18
|
-
stylesheet_link_tag
|
18
|
+
stylesheet_link_tag(URI.join(controller.class::BULMA_CDN, 'npm/bulma@0.9.3/css/bulma.css'),
|
19
19
|
media: :all,
|
20
|
-
integrity: '
|
21
|
-
crossorigin: 'anonymous'
|
20
|
+
integrity: 'sha384-Zkr9rpl37lclZu6AwYQZZm0CxiMqLZFiibodW+UXLnAWPBr6qgIzPpcmHkpwnyWD',
|
21
|
+
crossorigin: 'anonymous') unless request.xhr?
|
22
22
|
%>
|
23
23
|
|
24
|
-
<style
|
24
|
+
<style>
|
25
25
|
.ruby-comment { color: #6a737d;}
|
26
26
|
.ruby-const { color: #e36209; }
|
27
27
|
.ruby-embexpr-beg, .ruby-embexpr-end, .ruby-period { color: #24292e; }
|
@@ -31,12 +31,30 @@
|
|
31
31
|
.ruby-label, .ruby-tstring-beg, .ruby-tstring-content, .ruby-tstring-end { color: #032f62; }
|
32
32
|
</style>
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
<script>
|
35
|
+
function refresh() {
|
36
|
+
if (!("refresh" in document.body.dataset)) return
|
37
|
+
window.setTimeout(() => {
|
38
|
+
document.body.style.cursor = "wait"
|
39
|
+
fetch(document.location, { headers: { "X-Requested-With": "XMLHttpRequest" } }).then(
|
40
|
+
async response => {
|
41
|
+
const text = await response.text()
|
42
|
+
const newDocument = new DOMParser().parseFromString(text, "text/html")
|
43
|
+
document.body.replaceWith(newDocument.body)
|
44
|
+
<%# force a redraw for Safari %>
|
45
|
+
window.scrollTo({ top: document.documentElement.scrollTop + 1 })
|
46
|
+
window.scrollTo({ top: document.documentElement.scrollTop - 1 })
|
47
|
+
refresh()
|
48
|
+
},
|
49
|
+
error => location.reload()
|
50
|
+
)
|
51
|
+
}, 3000)
|
52
|
+
}
|
53
|
+
document.addEventListener('DOMContentLoaded', refresh)
|
54
|
+
</script>
|
37
55
|
</head>
|
38
56
|
|
39
|
-
|
57
|
+
<%= tag.body(data: { refresh: defined?(@refresh) && @refresh }) do %>
|
40
58
|
<%= render 'layouts/maintenance_tasks/navbar' %>
|
41
59
|
|
42
60
|
<section class="section">
|
@@ -50,5 +68,5 @@
|
|
50
68
|
<%= yield %>
|
51
69
|
</div>
|
52
70
|
</div>
|
53
|
-
|
71
|
+
<% end %>
|
54
72
|
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ChangeRunsTickColumnsToBigints < ActiveRecord::Migration[6.0]
|
4
|
+
def up
|
5
|
+
change_table(:maintenance_tasks_runs, bulk: true) do |t|
|
6
|
+
t.change(:tick_count, :bigint)
|
7
|
+
t.change(:tick_total, :bigint)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def down
|
12
|
+
change_table(:maintenance_tasks_runs, bulk: true) do |t|
|
13
|
+
t.change(:tick_count, :integer)
|
14
|
+
t.change(:tick_total, :integer)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require
|
2
|
+
require "rails_helper"
|
3
3
|
|
4
4
|
module <%= tasks_module %>
|
5
5
|
<% module_namespacing do -%>
|
6
6
|
RSpec.describe <%= class_name %>Task do
|
7
7
|
describe "#process" do
|
8
8
|
subject(:process) { described_class.process(element) }
|
9
|
-
let(:element) {
|
9
|
+
let(:element) {
|
10
10
|
# Object to be processed in a single iteration of this task
|
11
11
|
}
|
12
12
|
pending "add some examples to (or delete) #{__FILE__}"
|
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.
|
4
|
+
version: 1.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- db/migrate/20210225152418_remove_index_on_task_name.rb
|
134
134
|
- db/migrate/20210517131953_add_arguments_to_maintenance_tasks_runs.rb
|
135
135
|
- db/migrate/20211210152329_add_lock_version_to_maintenance_tasks_runs.rb
|
136
|
+
- db/migrate/20220706101937_change_runs_tick_columns_to_bigints.rb
|
136
137
|
- exe/maintenance_tasks
|
137
138
|
- lib/generators/maintenance_tasks/install_generator.rb
|
138
139
|
- lib/generators/maintenance_tasks/task_generator.rb
|
@@ -151,7 +152,7 @@ homepage: https://github.com/Shopify/maintenance_tasks
|
|
151
152
|
licenses:
|
152
153
|
- MIT
|
153
154
|
metadata:
|
154
|
-
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.
|
155
|
+
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.10.2
|
155
156
|
allowed_push_host: https://rubygems.org
|
156
157
|
post_install_message:
|
157
158
|
rdoc_options: []
|
@@ -168,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
172
|
+
rubygems_version: 3.3.3
|
172
173
|
signing_key:
|
173
174
|
specification_version: 4
|
174
175
|
summary: A Rails engine for queuing and managing maintenance tasks
|