2024-09-18 16:33:36 +02:00
|
|
|
# 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!
|
2024-09-19 13:25:21 +02:00
|
|
|
source_paths << Rails.root.join("lib/templates/maintenance_tasks")
|
2024-09-18 16:33:36 +02:00
|
|
|
|
|
|
|
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
|