maintenance_tasks 1.8.1 → 1.8.2

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: 6dbf3120a28de1ce88571561ba3be52d160743d365f862a65573b24fcc64cc24
4
- data.tar.gz: 87fda9aaf48c7643a85cc542cbda6d89721ea0b656396329abd9a2d4a42cab68
3
+ metadata.gz: b11e5edbefa677caf704bd6af59a14185ab89ff29da35d966253b78143a76af1
4
+ data.tar.gz: a103be6c53d5d6dae55d63f451d293abe1c0a4e763cb1c2bd9e3dcfea3a6bc72
5
5
  SHA512:
6
- metadata.gz: 77cc4fad4f591683cb3b6062265c487efb8f15b7f31aca2620730af3b74dd57296f8451d7077256fe2f5718762b8ba3de76e7f1affe2c888c202c585a781a570
7
- data.tar.gz: 15e9c05f39cc0cc6216b66081ec051eebd4a669e5c5e002672f2028d5a160fa8dd4a9144e726bc455aa7a60b96018c2fe1a572079a9d705d7b299b7762e483df
6
+ metadata.gz: 3415d87b545e09fc65494cecb03a7cea9a5c84838c66c209a129f8017efc611eee7521852c2460ada50c389b2885bb95dcd2bfe807ea8a84693e9b86e2123409
7
+ data.tar.gz: 19fce32dfc506afe512ce6ebc2ddfd0a2fd195b61e4611c4a3febae5ad4bfe09d39ac47e902a1c21f830de9e3c5f953379d8011919ba0a381dc6010599eb289e
@@ -47,6 +47,7 @@ module MaintenanceTasks
47
47
  a batch enumerator with the "start" or "finish" options.
48
48
  MSG
49
49
  end
50
+
50
51
  # For now, only support automatic count based on the enumerator for
51
52
  # batches
52
53
  @enumerator = enumerator_builder.active_record_on_batch_relations(
@@ -151,7 +152,7 @@ module MaintenanceTasks
151
152
  def after_perform
152
153
  @run.persist_transition
153
154
  if defined?(@reenqueue_iteration_job) && @reenqueue_iteration_job
154
- reenqueue_iteration_job(should_ignore: false)
155
+ reenqueue_iteration_job(should_ignore: false) unless @run.stopped?
155
156
  end
156
157
  end
157
158
 
@@ -52,6 +52,7 @@ module MaintenanceTasks
52
52
  # Ensure ActiveStorage is in use before preloading the attachments
53
53
  scope :with_attached_csv, -> do
54
54
  return unless defined?(ActiveStorage)
55
+
55
56
  with_attached_csv_file if ActiveStorage::Attachment.table_exists?
56
57
  end
57
58
 
@@ -240,6 +241,7 @@ module MaintenanceTasks
240
241
  # Preserve swap-and-replace solution for data races until users
241
242
  # run migration to upgrade to optimistic locking solution
242
243
  return if stopping?
244
+
243
245
  updated = self.class.where(id: id).where.not(status: STOPPING_STATUSES)
244
246
  .update_all(status: :running, updated_at: Time.now) > 0
245
247
  if updated
@@ -384,6 +386,7 @@ module MaintenanceTasks
384
386
  def csv_file
385
387
  return unless defined?(ActiveStorage)
386
388
  return unless ActiveStorage::Attachment.table_exists?
389
+
387
390
  super
388
391
  end
389
392
 
@@ -426,6 +429,7 @@ module MaintenanceTasks
426
429
  def truncate(attribute_name, value)
427
430
  limit = self.class.column_for_attribute(attribute_name).limit
428
431
  return value unless limit
432
+
429
433
  value&.first(limit)
430
434
  end
431
435
  end
@@ -38,6 +38,7 @@ module MaintenanceTasks
38
38
  unless task.is_a?(Class) && task < Task
39
39
  raise NotFoundError.new("#{name} is not a Task.", name)
40
40
  end
41
+
41
42
  task
42
43
  end
43
44
 
@@ -172,6 +173,7 @@ module MaintenanceTasks
172
173
  def load_constants
173
174
  namespace = MaintenanceTasks.tasks_module.safe_constantize
174
175
  return unless namespace
176
+
175
177
  namespace.constants.map { |constant| namespace.const_get(constant) }
176
178
  end
177
179
  end
@@ -73,6 +73,7 @@ module MaintenanceTasks
73
73
  # @return [nil] if the Task file was deleted.
74
74
  def code
75
75
  return if deleted?
76
+
76
77
  task = Task.named(name)
77
78
  file = if Object.respond_to?(:const_source_location)
78
79
  Object.const_source_location(task.name).first
@@ -88,6 +89,7 @@ module MaintenanceTasks
88
89
  # @return [nil] if there are no Runs associated with the Task.
89
90
  def last_run
90
91
  return @last_run if defined?(@last_run)
92
+
91
93
  @last_run = runs.first
92
94
  end
93
95
 
@@ -100,6 +102,7 @@ module MaintenanceTasks
100
102
  # record previous to the last Run.
101
103
  def previous_runs
102
104
  return Run.none unless last_run
105
+
103
106
  runs.where.not(id: last_run.id)
104
107
  end
105
108
 
@@ -150,6 +153,7 @@ module MaintenanceTasks
150
153
  # @return [nil] if the Task file was deleted.
151
154
  def new
152
155
  return if deleted?
156
+
153
157
  MaintenanceTasks::Task.named(name).new
154
158
  end
155
159
 
@@ -41,6 +41,7 @@ module MaintenanceTasks
41
41
  # row will call the block at most once (if it had been throttled).
42
42
  def persist
43
43
  return if @ticks_recorded == 0
44
+
44
45
  now = Time.now
45
46
  duration = now - @last_persisted
46
47
  @last_persisted = now
@@ -66,6 +66,7 @@ module MaintenanceTasks
66
66
  # @private
67
67
  def self.error_handler
68
68
  return @error_handler if defined?(@error_handler)
69
+
69
70
  @error_handler = ->(_error, _task_context, _errored_element) {}
70
71
  end
71
72
 
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.8.1
4
+ version: 1.8.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-02-25 00:00:00.000000000 Z
11
+ date: 2022-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.1'
61
+ version: 1.3.6
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.1'
68
+ version: 1.3.6
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: railties
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -150,7 +150,7 @@ homepage: https://github.com/Shopify/maintenance_tasks
150
150
  licenses:
151
151
  - MIT
152
152
  metadata:
153
- source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.8.1
153
+ source_code_uri: https://github.com/Shopify/maintenance_tasks/tree/v1.8.2
154
154
  allowed_push_host: https://rubygems.org
155
155
  post_install_message:
156
156
  rdoc_options: []