Class: Actions::CheckLongRunningTasks
- Inherits:
-
EntryAction
- Object
- Dynflow::Action
- Base
- EntryAction
- Actions::CheckLongRunningTasks
- Includes:
- RecurringAction
- Defined in:
- app/lib/actions/check_long_running_tasks.rb
Constant Summary collapse
- INTERVAL =
2.days
- STATES =
['running', 'paused'].freeze
Instance Method Summary collapse
Methods included from RecurringAction
Methods inherited from EntryAction
#action_subject, all_action_names, #delay, #drop_all_locks!, #humanized_input, #resource_locks, serializer_class
Methods included from Helpers::Lock
#exclusive_lock!, #link!, #lock!
Methods included from Helpers::ArgsSerialization
Methods inherited from Base
#already_running?, #humanized_errors, #humanized_input, #humanized_output, #notify_paused, #serializer_class, #task, #task_input, #task_output
Methods included from TaskSynchronization
included, #sync_execution_plan_to_task
Methods included from Helpers::LifecycleLogging
included, #log_task_state_change
Instance Method Details
#humanized_name ⇒ Object
39 40 41 |
# File 'app/lib/actions/check_long_running_tasks.rb', line 39 def humanized_name _('Check for long running tasks') end |
#plan ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/lib/actions/check_long_running_tasks.rb', line 8 def plan time = Time.now.utc cutoff = time - INTERVAL users = User.joins(:mail_notifications) .where(mail_enabled: true, mail_notifications: { name: 'long_running_tasks' }) .where.not(mail: [nil, '']) .where(disabled: [nil, false]) query = "state ^ (#{STATES.join(', ')}) AND state_updated_at <= \"#{cutoff}\"" users.each do |user| User.as(user) do tasks = ForemanTasks::Task. .search_for(query) .select(:id) .pluck(:id) plan_action(DeliverLongRunningTasksNotification, OpenStruct.new( user_id: User.current.id, time: time, interval: INTERVAL, states: STATES, task_uuids: tasks, query: query, # Non serializable fields user: nil, tasks: nil )) end end end |
#rescue_strategy_for_self ⇒ Object
43 44 45 |
# File 'app/lib/actions/check_long_running_tasks.rb', line 43 def rescue_strategy_for_self Dynflow::Action::Rescue::Skip end |