feat: sla-2 add automation backend support for SLA (#8775)
* feat: add automation support for SLA * feat: add sla action in automtion UI * chore: revert frontend changes * chore: refactor to ee namespace * chore: refactor automation rule to ee namespace * feat: create applied_sla table entry * chore: add applied_sla spec * chore: rubocop fixes --------- Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
9
enterprise/app/models/enterprise/automation_rule.rb
Normal file
9
enterprise/app/models/enterprise/automation_rule.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
module Enterprise::AutomationRule
|
||||
def conditions_attributes
|
||||
super + %w[sla_policy_id]
|
||||
end
|
||||
|
||||
def actions_attributes
|
||||
super + %w[add_sla]
|
||||
end
|
||||
end
|
||||
15
enterprise/app/services/enterprise/action_service.rb
Normal file
15
enterprise/app/services/enterprise/action_service.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Enterprise::ActionService
|
||||
def add_sla(sla_policy)
|
||||
@conversation.update!(sla_policy_id: sla_policy.id)
|
||||
create_applied_sla(sla_policy)
|
||||
end
|
||||
|
||||
def create_applied_sla(sla_policy)
|
||||
AppliedSla.create!(
|
||||
account_id: @conversation.account_id,
|
||||
sla_policy_id: sla_policy.id,
|
||||
conversation_id: @conversation.id,
|
||||
sla_status: 'active'
|
||||
)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user