feat(tasks): use our task template, with example doc
This commit is contained in:
parent
cbc13c4c5c
commit
c0ae02f458
2 changed files with 26 additions and 0 deletions
|
@ -6,6 +6,7 @@ Rails.application.config.after_initialize do
|
||||||
|
|
||||||
class MaintenanceTasks::TaskGenerator
|
class MaintenanceTasks::TaskGenerator
|
||||||
alias_method :original_assign_names!, :assign_names!
|
alias_method :original_assign_names!, :assign_names!
|
||||||
|
source_paths << Rails.root.join("lib/templates/maintenance_tasks")
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
|
25
lib/templates/maintenance_tasks/task.rb.tt
Normal file
25
lib/templates/maintenance_tasks/task.rb.tt
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module <%= tasks_module %>
|
||||||
|
<% module_namespacing do -%>
|
||||||
|
class <%= class_name %>Task < MaintenanceTasks::Task
|
||||||
|
# Documentation: cette tâche modifie les données pour…
|
||||||
|
|
||||||
|
def collection
|
||||||
|
# Collection to be iterated over
|
||||||
|
# Must be Active Record Relation or Array
|
||||||
|
end
|
||||||
|
|
||||||
|
def process(element)
|
||||||
|
# The work to be done in a single iteration of the task.
|
||||||
|
# This should be idempotent, as the same element may be processed more
|
||||||
|
# than once if the task is interrupted and resumed.
|
||||||
|
end
|
||||||
|
|
||||||
|
def count
|
||||||
|
# Optionally, define the number of rows that will be iterated over
|
||||||
|
# This is used to track the task's progress
|
||||||
|
end
|
||||||
|
end
|
||||||
|
<% end -%>
|
||||||
|
end
|
Loading…
Reference in a new issue