maintenance_tasks 1.10.0 → 1.10.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd4ace45bec0d57e14080ddf832419d1daa1a06fc8cb7d7e79af2c14b2e9c26c
4
- data.tar.gz: 698945e60d17b43eeab9da5a3f43aa68fb0d9841f2aad1f66fc0c1f2994a4bc5
3
+ metadata.gz: de43aad0e8d7479e1f7a88d8f664e20213d42455ca85ef22e074e2321b9a183b
4
+ data.tar.gz: 65bae8e5b9f793e5cd4dc08dfee03611378007d571d5fc027b349faa7c358b74
5
5
  SHA512:
6
- metadata.gz: 5a4c862c0eddbf87fd0196b390eb6cc01b7dbe56d08772c4afb23e7cbaf351a6a9328e4c8bdf66057b4e871c099983649b6acddb6371fc7f216bb226b9ba372c
7
- data.tar.gz: f7da9ab1b727fc9be10900da568a59c8c7a6a9620e7619f879942a5489b56ab673c8efcfbfc0551d54f018df0baef1638220854a2f88c7c0824bcfb6ccbaf222
6
+ metadata.gz: 5b088335a8ef4a0e1e92d376f4c5c2d2c05ca2dea2e07aa983f21783ce5a7bff53cf3b4f2a75607d67fea144119078f563882f6e67c6fd09adc3d20ebac285a1
7
+ data.tar.gz: '0128f6891b9b0328b7ba80490b4843a70eb014ddb82295d50f7d22218164ac3e9ef1e7c08bb80e8aab0a4501e932a1d374e755e7f21bd709c996f33b3344575f'
@@ -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
- (task.csv_content.count("\n") + @batch_size - 1) / @batch_size
36
+ count = task.csv_content.count("\n") - 1
37
+ (count + @batch_size - 1) / @batch_size
37
38
  end
38
39
  end
39
40
  end
@@ -29,6 +29,7 @@ module MaintenanceTasks
29
29
  STOPPING_STATUSES = [
30
30
  :pausing,
31
31
  :cancelling,
32
+ :cancelled,
32
33
  ]
33
34
  COMPLETED_STATUSES = [:succeeded, :errored, :cancelled]
34
35
  COMPLETED_RUNS_LIMIT = 10
@@ -137,7 +138,7 @@ module MaintenanceTasks
137
138
  backtrace: MaintenanceTasks.backtrace_cleaner.clean(error.backtrace),
138
139
  ended_at: Time.now,
139
140
  )
140
- run_task_callbacks(:error)
141
+ run_error_callback
141
142
  rescue ActiveRecord::StaleObjectError
142
143
  reload_status
143
144
  retry
@@ -168,8 +169,10 @@ module MaintenanceTasks
168
169
  self
169
170
  end
170
171
 
171
- # Returns whether the Run is stopping, which is defined as
172
- # having a status of pausing or cancelled.
172
+ # Returns whether the Run is stopping, which is defined as having a status
173
+ # of pausing or cancelling. The status of cancelled is also considered
174
+ # stopping since a Run can be cancelled while its job still exists in the
175
+ # queue, and we want to handle it the same way as a cancelling run.
173
176
  #
174
177
  # @return [Boolean] whether the Run is stopping.
175
178
  def stopping?
@@ -259,7 +262,7 @@ module MaintenanceTasks
259
262
  # specified by the Task.
260
263
  def start(count)
261
264
  update!(started_at: Time.now, tick_total: count)
262
- run_task_callbacks(:start)
265
+ task.run_callbacks(:start)
263
266
  rescue ActiveRecord::StaleObjectError
264
267
  reload_status
265
268
  retry
@@ -272,6 +275,7 @@ module MaintenanceTasks
272
275
  self.ended_at = Time.now
273
276
  elsif pausing?
274
277
  self.status = :paused
278
+ elsif cancelled?
275
279
  else
276
280
  self.status = :interrupted
277
281
  end
@@ -412,6 +416,12 @@ module MaintenanceTasks
412
416
 
413
417
  def run_task_callbacks(callback)
414
418
  task.run_callbacks(callback)
419
+ rescue Task::NotFoundError
420
+ nil
421
+ end
422
+
423
+ def run_error_callback
424
+ task.run_callbacks(:error)
415
425
  rescue
416
426
  nil
417
427
  end
@@ -54,7 +54,7 @@
54
54
  </script>
55
55
  </head>
56
56
 
57
- <body <%= "data-refresh" if defined?(@refresh) && @refresh %>>
57
+ <%= tag.body(data: { refresh: defined?(@refresh) && @refresh }) do %>
58
58
  <%= render 'layouts/maintenance_tasks/navbar' %>
59
59
 
60
60
  <section class="section">
@@ -68,5 +68,5 @@
68
68
  <%= yield %>
69
69
  </div>
70
70
  </div>
71
- </body>
71
+ <% end %>
72
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
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.10.0
4
+ version: 1.10.3
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-05-06 00:00:00.000000000 Z
11
+ date: 2022-09-02 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.10.0
155
+ source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.10.3
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.2.20
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