feat(tasks): prefix tasks with timestamp
This commit is contained in:
parent
d51d3fd8ad
commit
cbc13c4c5c
1 changed files with 19 additions and 0 deletions
19
config/initializers/maintenance_tasks.rb
Normal file
19
config/initializers/maintenance_tasks.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
Rails.application.config.after_initialize do
|
||||||
|
if defined?(Rails::Generators)
|
||||||
|
require "generators/maintenance_tasks/task_generator"
|
||||||
|
|
||||||
|
class MaintenanceTasks::TaskGenerator
|
||||||
|
alias_method :original_assign_names!, :assign_names!
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# Prefix the task name with a date so the tasks are better sorted.
|
||||||
|
def assign_names!(name)
|
||||||
|
timestamped_name = "T#{Date.current.strftime("%Y%m%d")}#{name}"
|
||||||
|
original_assign_names!(timestamped_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue