feat: Conversation API to return applied_sla and sla_events (#9174)

* chore: Add sla_events to push_event_data

* chore: Return SLA details in the API

* chore: feature lock sla push event data

* Update _conversation.json.jbuilder

* chore: rubocop fixes
This commit is contained in:
Sojan Jose
2024-04-01 23:30:07 +05:30
committed by GitHub
parent 16282f6a66
commit 4e28481f27
20 changed files with 198 additions and 13 deletions

View File

@@ -25,3 +25,4 @@ class ApplicationController < ActionController::Base
}
end
end
ApplicationController.include_mod_with('Concerns::ApplicationControllerConcern')

View File

@@ -163,10 +163,14 @@ class ConversationFinder
params[:page] || 1
end
def conversations
@conversations = @conversations.includes(
def conversations_base_query
@conversations.includes(
:taggings, :inbox, { assignee: { avatar_attachment: [:blob] } }, { contact: { avatar_attachment: [:blob] } }, :team, :contact_inbox
)
end
def conversations
@conversations = conversations_base_query
sort_by, sort_order = SORT_OPTIONS[params[:sort_by]] || SORT_OPTIONS['last_activity_at_desc']
@conversations = @conversations.send(sort_by, sort_order)
@@ -178,3 +182,4 @@ class ConversationFinder
end
end
end
ConversationFinder.prepend_mod_with('ConversationFinder')

View File

@@ -312,5 +312,5 @@ class Conversation < ApplicationRecord
end
end
Conversation.include_mod_with('EnterpriseConversationConcern')
Conversation.include_mod_with('Concerns::Conversation')
Conversation.include_mod_with('SentimentAnalysisHelper')

View File

@@ -45,3 +45,4 @@ class Conversations::EventDataPresenter < SimpleDelegator
}
end
end
Conversations::EventDataPresenter.prepend_mod_with('Conversations::EventDataPresenter')

View File

@@ -1,3 +1,7 @@
# TODO: Move this into models jbuilder
# Currently the file there is used only for search endpoint.
# Everywhere else we use conversation builder in partials folder
json.meta do
json.sender do
json.partial! 'api/v1/models/contact', formats: [:json], resource: conversation.contact
@@ -48,3 +52,4 @@ json.last_activity_at conversation.last_activity_at.to_i
json.priority conversation.priority
json.waiting_since conversation.waiting_since.to_i.to_i
json.sla_policy_id conversation.sla_policy_id
json.partial! 'enterprise/api/v1/conversations/partials/conversation', conversation: conversation if ChatwootApp.enterprise?

View File

@@ -1,3 +1,5 @@
# This file is used to render conversation data search API response.
json.id conversation.display_id
json.uuid conversation.uuid
json.created_at conversation.created_at.to_i