Class: Decidim::Cdtb::Task
- Inherits:
-
Object
- Object
- Decidim::Cdtb::Task
- Includes:
- TasksUtils
- Defined in:
- lib/decidim/cdtb/task.rb
Overview
Parent class with common behaviour for all tasks.
Direct Known Subclasses
Fixes::NicknameFixer, Fixes::YouTubeEmbedsFixer, Multitenants::OrgByHostLike, ParticipatorySpaces::AddContentBlocks, ParticipatorySpaces::MoveImagesToContentBlock, Spam::SpamUsersDetector, Storage::LocalSharding, Storage::SetLocalOnBlobs, Upgrades::UpgradeModulesTask, Upgrades::ValidateMigrationsTask, Users::Remover
Instance Attribute Summary collapse
-
#num_applied ⇒ Object
readonly
Returns the value of attribute num_applied.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #execute! ⇒ Object
- #finish ⇒ Object
- #init ⇒ Object
-
#initialize(title, progress_bar: nil) ⇒ Task
constructor
title: The title shown at the begining of the Task progress_bar: A hash with one key: :title for the title of the ProgressBar.
Methods included from TasksUtils
#do_log_error, #do_log_info, #log_task_end, #log_task_failure, #log_task_info, #log_task_step, #log_task_title, #logger
Constructor Details
#initialize(title, progress_bar: nil) ⇒ Task
title: The title shown at the begining of the Task progress_bar: A hash with one key: :title for the title of the ProgressBar.
14 15 16 17 18 |
# File 'lib/decidim/cdtb/task.rb', line 14 def initialize(title, progress_bar: nil) @title= title @progress_bar= @num_applied = 0 end |
Instance Attribute Details
#num_applied ⇒ Object (readonly)
Returns the value of attribute num_applied.
20 21 22 |
# File 'lib/decidim/cdtb/task.rb', line 20 def num_applied @num_applied end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
20 21 22 |
# File 'lib/decidim/cdtb/task.rb', line 20 def title @title end |
Instance Method Details
#execute! ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/decidim/cdtb/task.rb', line 28 def execute! init ctx= {} prepare_execution(ctx) ctx[:progress_bar]= ProgressBar.create(total: total_items, title:) if has_progress? do_execution(ctx) end_execution(ctx) finish end |
#finish ⇒ Object
38 39 40 41 |
# File 'lib/decidim/cdtb/task.rb', line 38 def finish do_log_info("⏱️ Took #{Time.zone.now - @start_time} seconds") log_task_end end |
#init ⇒ Object
22 23 24 25 26 |
# File 'lib/decidim/cdtb/task.rb', line 22 def init log_task_title(@title) @start_time= Time.zone.now do_log_info("▶️ Starting at #{@start_time}") end |