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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2dcb5b54d6f3fd47db28a3f57a487c201e2109b3eb8f78efbe3c972a374999e8
4
- data.tar.gz: eeb95960a0cac8de08aa3af7d12d47f6cfbee4d875ab74f8989f4d17ef545f6c
3
+ metadata.gz: c395c28308277378c5ac627845abc512bba455e11e085558aa4ef106f73b1130
4
+ data.tar.gz: 7e44c8b5c484aa44008e2ebd3dd35458f84dec2be2741c20cc1ae20871c10f48
5
5
  SHA512:
6
- metadata.gz: e99ebde772755c6f3d88d48e65df883805b2ceb4798334f00175bc8e4c83d093bef79931bf0c0c86b303c3d94d2e0b44b3b506b1813ea6e01597ccf47f2c8182
7
- data.tar.gz: 58d11ad3fa36721e9f29a49cecf586d2f362aaf155667ce6b7702b7acd7bb43f1defa2a2a4ed1fa259d563876b9cec5d5f7b66f4d5dcf43747009e64552fa804
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
@@ -15,7 +15,7 @@ module MaintenanceTasks
15
15
  )
16
16
  policy.script_src(
17
17
  # page refresh script
18
- "'sha256-2RPaBS4XCMLp0JJ/sW407W9l4qjC+WQAHmTOFJTGfqo='",
18
+ "'sha256-NiHKryHWudRC2IteTqmY9v1VkaDUA/5jhgXkMTkgo2w='",
19
19
  )
20
20
  policy.frame_ancestors(:self)
21
21
  end
@@ -175,7 +175,13 @@ module MaintenanceTasks
175
175
  namespace = MaintenanceTasks.tasks_module.safe_constantize
176
176
  return unless namespace
177
177
 
178
- namespace.constants.map { |constant| namespace.const_get(constant) }
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
- if (!("refresh" in document.body.dataset)) return
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
- 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 })
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
- <%= tag.body(data: { refresh: defined?(@refresh) && @refresh }) do %>
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
- <% end %>
73
+ </body>
72
74
  </html>
@@ -1,22 +1,24 @@
1
- <% if @available_tasks.empty? %>
2
- <div class="content is-large">
3
- <h3 class="title is-3"> The MaintenanceTasks gem has been successfully installed! </h3>
4
- <p>
5
- Any new Tasks will show up here. To start writing your first Task,
6
- run <code>bin/rails generate maintenance_tasks:task my_task</code>.
7
- </p>
8
- </div>
9
- <% else %>
10
- <% if active_tasks = @available_tasks[:active] %>
11
- <h3 class="title is-3">Active Tasks</h3>
12
- <%= render partial: 'task', collection: active_tasks %>
13
- <% end %>
14
- <% if new_tasks = @available_tasks[:new] %>
15
- <h3 class="title is-3">New Tasks</h3>
16
- <%= render partial: 'task', collection: new_tasks %>
17
- <% end %>
18
- <% if completed_tasks = @available_tasks[:completed] %>
19
- <h3 class="title is-3">Completed Tasks</h3>
20
- <%= render partial: 'task', collection: completed_tasks %>
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
- <% if @task.active_runs.any? %>
42
- <hr/>
41
+ <%= tag.div(data: { refresh: (defined?(@refresh) && @refresh) || "" }) do %>
42
+ <% if @task.active_runs.any? %>
43
+ <hr/>
43
44
 
44
- <h4 class="title is-4">Active Runs</h4>
45
+ <h4 class="title is-4">Active Runs</h4>
45
46
 
46
- <%= render @task.active_runs %>
47
- <% end %>
47
+ <%= render @task.active_runs %>
48
+ <% end %>
48
49
 
49
- <% if @runs_page.records.present? %>
50
- <hr/>
50
+ <% if @runs_page.records.present? %>
51
+ <hr/>
51
52
 
52
- <h4 class="title is-4">Previous Runs</h4>
53
+ <h4 class="title is-4">Previous Runs</h4>
53
54
 
54
- <%= render @runs_page.records %>
55
+ <%= render @runs_page.records %>
55
56
 
56
- <%= link_to "Next page", task_path(@task, cursor: @runs_page.next_cursor) unless @runs_page.last? %>
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.0
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-02-27 00:00:00.000000000 Z
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.0
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.3.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