maintenance_tasks 2.1.0 → 2.1.1
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 +20 -0
- data/app/controllers/maintenance_tasks/application_controller.rb +1 -1
- data/app/models/maintenance_tasks/task.rb +7 -1
- data/app/views/layouts/maintenance_tasks/application.html.erb +9 -7
- data/app/views/maintenance_tasks/tasks/index.html.erb +22 -20
- data/app/views/maintenance_tasks/tasks/show.html.erb +12 -10
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c395c28308277378c5ac627845abc512bba455e11e085558aa4ef106f73b1130
|
4
|
+
data.tar.gz: 7e44c8b5c484aa44008e2ebd3dd35458f84dec2be2741c20cc1ae20871c10f48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 825418a040b4b15f0a98c5e28b06c553e240ec7b0ba10b2adec7b28180203d3e7094cb4e4b2933076d7564050b42f33504ede5b830e1819274393cf9d574f058
|
7
|
+
data.tar.gz: d2d7aa0c97a37851d8540edea5a4e890b1eeb9fbfc740c157070558fbc51e60ef9d3ff882b5ab21cd9b80481f7b2692d9a3f8fbaa03bbdcd4256f1b51aa669ce
|
data/README.md
CHANGED
@@ -696,6 +696,26 @@ MaintenanceTasks.tasks_module = "TaskModule"
|
|
696
696
|
|
697
697
|
If no value is specified, it will default to `Maintenance`.
|
698
698
|
|
699
|
+
#### Organizing tasks using namespaces
|
700
|
+
|
701
|
+
Tasks may be nested arbitrarily deeply under `app/tasks/maintenance`, for example given a
|
702
|
+
task file `app/tasks/maintenance/team_name/service_name/update_posts_task.rb` we
|
703
|
+
can define the task as:
|
704
|
+
|
705
|
+
```ruby
|
706
|
+
module Maintenance
|
707
|
+
module TeamName
|
708
|
+
module ServiceName
|
709
|
+
class UpdatePostsTask < MaintenanceTasks::Task
|
710
|
+
def process(rows)
|
711
|
+
# ...
|
712
|
+
end
|
713
|
+
end
|
714
|
+
end
|
715
|
+
end
|
716
|
+
end
|
717
|
+
```
|
718
|
+
|
699
719
|
#### Customizing the underlying job class
|
700
720
|
|
701
721
|
`MaintenanceTasks.job` can be configured to define a Job class for your tasks to
|
@@ -175,7 +175,13 @@ module MaintenanceTasks
|
|
175
175
|
namespace = MaintenanceTasks.tasks_module.safe_constantize
|
176
176
|
return unless namespace
|
177
177
|
|
178
|
-
|
178
|
+
load_const = lambda do |root|
|
179
|
+
root.constants.each do |name|
|
180
|
+
object = root.const_get(name)
|
181
|
+
load_const.call(object) if object.instance_of?(Module)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
load_const.call(namespace)
|
179
185
|
end
|
180
186
|
end
|
181
187
|
|
@@ -33,17 +33,19 @@
|
|
33
33
|
|
34
34
|
<script>
|
35
35
|
function refresh() {
|
36
|
-
|
36
|
+
const target = document.querySelector("[data-refresh]")
|
37
|
+
if (!target || !target.dataset.refresh) return
|
37
38
|
window.setTimeout(() => {
|
38
39
|
document.body.style.cursor = "wait"
|
39
40
|
fetch(document.location, { headers: { "X-Requested-With": "XMLHttpRequest" } }).then(
|
40
41
|
async response => {
|
41
42
|
const text = await response.text()
|
42
43
|
const newDocument = new DOMParser().parseFromString(text, "text/html")
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
const newTarget = newDocument.querySelector("[data-refresh]")
|
45
|
+
if (newTarget) {
|
46
|
+
target.replaceWith(newTarget)
|
47
|
+
}
|
48
|
+
document.body.style.cursor = ""
|
47
49
|
refresh()
|
48
50
|
},
|
49
51
|
error => location.reload()
|
@@ -54,7 +56,7 @@
|
|
54
56
|
</script>
|
55
57
|
</head>
|
56
58
|
|
57
|
-
|
59
|
+
<body>
|
58
60
|
<%= render 'layouts/maintenance_tasks/navbar' %>
|
59
61
|
|
60
62
|
<section class="section">
|
@@ -68,5 +70,5 @@
|
|
68
70
|
<%= yield %>
|
69
71
|
</div>
|
70
72
|
</div>
|
71
|
-
|
73
|
+
</body>
|
72
74
|
</html>
|
@@ -1,22 +1,24 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
<
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<%
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
<%= tag.div(data: { refresh: (defined?(@refresh) && @refresh) || "" }) do %>
|
2
|
+
<% if @available_tasks.empty? %>
|
3
|
+
<div class="content is-large">
|
4
|
+
<h3 class="title is-3"> The MaintenanceTasks gem has been successfully installed! </h3>
|
5
|
+
<p>
|
6
|
+
Any new Tasks will show up here. To start writing your first Task,
|
7
|
+
run <code>bin/rails generate maintenance_tasks:task my_task</code>.
|
8
|
+
</p>
|
9
|
+
</div>
|
10
|
+
<% else %>
|
11
|
+
<% if active_tasks = @available_tasks[:active] %>
|
12
|
+
<h3 class="title is-3">Active Tasks</h3>
|
13
|
+
<%= render partial: 'task', collection: active_tasks %>
|
14
|
+
<% end %>
|
15
|
+
<% if new_tasks = @available_tasks[:new] %>
|
16
|
+
<h3 class="title is-3">New Tasks</h3>
|
17
|
+
<%= render partial: 'task', collection: new_tasks %>
|
18
|
+
<% end %>
|
19
|
+
<% if completed_tasks = @available_tasks[:completed] %>
|
20
|
+
<h3 class="title is-3">Completed Tasks</h3>
|
21
|
+
<%= render partial: 'task', collection: completed_tasks %>
|
22
|
+
<% end %>
|
21
23
|
<% end %>
|
22
24
|
<% end %>
|
@@ -38,20 +38,22 @@
|
|
38
38
|
<pre><code><%= highlight_code(code) %></code></pre>
|
39
39
|
<% end %>
|
40
40
|
|
41
|
-
|
42
|
-
|
41
|
+
<%= tag.div(data: { refresh: (defined?(@refresh) && @refresh) || "" }) do %>
|
42
|
+
<% if @task.active_runs.any? %>
|
43
|
+
<hr/>
|
43
44
|
|
44
|
-
|
45
|
+
<h4 class="title is-4">Active Runs</h4>
|
45
46
|
|
46
|
-
|
47
|
-
<% end %>
|
47
|
+
<%= render @task.active_runs %>
|
48
|
+
<% end %>
|
48
49
|
|
49
|
-
<% if @runs_page.records.present? %>
|
50
|
-
|
50
|
+
<% if @runs_page.records.present? %>
|
51
|
+
<hr/>
|
51
52
|
|
52
|
-
|
53
|
+
<h4 class="title is-4">Previous Runs</h4>
|
53
54
|
|
54
|
-
|
55
|
+
<%= render @runs_page.records %>
|
55
56
|
|
56
|
-
|
57
|
+
<%= link_to "Next page", task_path(@task, cursor: @runs_page.next_cursor) unless @runs_page.last? %>
|
58
|
+
<% end %>
|
57
59
|
<% end %>
|
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: 2.1.
|
4
|
+
version: 2.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: 2023-
|
11
|
+
date: 2023-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -154,7 +154,7 @@ homepage: https://github.com/Shopify/maintenance_tasks
|
|
154
154
|
licenses:
|
155
155
|
- MIT
|
156
156
|
metadata:
|
157
|
-
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v2.1.
|
157
|
+
source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v2.1.1
|
158
158
|
allowed_push_host: https://rubygems.org
|
159
159
|
post_install_message:
|
160
160
|
rdoc_options: []
|
@@ -171,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
171
|
- !ruby/object:Gem::Version
|
172
172
|
version: '0'
|
173
173
|
requirements: []
|
174
|
-
rubygems_version: 3.
|
174
|
+
rubygems_version: 3.4.10
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: A Rails engine for queuing and managing maintenance tasks
|