Class: Actions::CheckLongRunningTasks
Constant Summary
collapse
- INTERVAL =
2.days
- STATES =
['running', 'paused'].freeze
Instance Method Summary
collapse
included, #trigger_repeat
Methods inherited from EntryAction
#action_subject, all_action_names, #delay, #drop_all_locks!, #humanized_input, #resource_locks, serializer_class
#exclusive_lock!, #link!
#serialize_args
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.authorized
.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,
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
|