feat: Add SLA metrics API (#9132)
This commit is contained in:
@@ -29,6 +29,17 @@ class AppliedSla < ApplicationRecord
|
||||
|
||||
enum sla_status: { active: 0, hit: 1, missed: 2 }
|
||||
|
||||
scope :filter_by_date_range, ->(range) { where(created_at: range) if range.present? }
|
||||
scope :filter_by_inbox_id, ->(inbox_id) { where(inbox_id: inbox_id) if inbox_id.present? }
|
||||
scope :filter_by_team_id, ->(team_id) { where(team_id: team_id) if team_id.present? }
|
||||
scope :filter_by_sla_policy_id, ->(sla_policy_id) { where(sla_policy_id: sla_policy_id) if sla_policy_id.present? }
|
||||
scope :filter_by_label_list, ->(label_list) { joins(:conversation).where(conversations: { cached_label_list: label_list }) if label_list.present? }
|
||||
scope :filter_by_assigned_agent_id, lambda { |assigned_agent_id|
|
||||
if assigned_agent_id.present?
|
||||
joins(:conversation).where(conversations: { assigned_agent_id: assigned_agent_id })
|
||||
end
|
||||
}
|
||||
scope :missed, -> { where(sla_status: :missed) }
|
||||
private
|
||||
|
||||
def ensure_account_id
|
||||
|
||||
Reference in New Issue
Block a user