Merge branch 'release/1.18.1'

This commit is contained in:
Sojan 2021-07-20 00:51:08 +05:30
commit caf8669db5
11 changed files with 51 additions and 23 deletions

View file

@ -21,6 +21,27 @@ class ConversationFinder
end
def perform
set_up
mine_count, unassigned_count, all_count, = set_count_for_all_conversations
assigned_count = all_count - unassigned_count
filter_by_assignee_type
{
conversations: conversations,
count: {
mine_count: mine_count,
assigned_count: assigned_count,
unassigned_count: unassigned_count,
all_count: all_count
}
}
end
private
def set_up
set_inboxes
set_team
set_assignee_type
@ -30,23 +51,8 @@ class ConversationFinder
filter_by_team if @team
filter_by_labels if params[:labels]
filter_by_query if params[:q]
mine_count, unassigned_count, all_count = set_count_for_all_conversations
filter_by_assignee_type
{
conversations: conversations,
count: {
mine_count: mine_count,
unassigned_count: unassigned_count,
all_count: all_count
}
}
end
private
def set_inboxes
@inbox_ids = if params[:inbox_id]
current_account.inboxes.where(id: params[:inbox_id])
@ -74,7 +80,7 @@ class ConversationFinder
when 'unassigned'
@conversations = @conversations.unassigned
when 'assigned'
@conversations = @conversations.where.not(assignee_id: nil)
@conversations = @conversations.assigned
end
@conversations
end

View file

@ -134,11 +134,17 @@ export default {
const {
email: {
html_content: { full: fullHTMLContent, reply: replyHTMLContent } = {},
text_content: { full: fullTextContent, reply: replyTextContent } = {},
} = {},
} = this.contentAttributes;
if ((replyHTMLContent || fullHTMLContent) && this.isIncoming) {
let contentToBeParsed = replyHTMLContent || fullHTMLContent || '';
let contentToBeParsed =
replyHTMLContent ||
replyTextContent ||
fullHTMLContent ||
fullTextContent ||
'';
if (contentToBeParsed && this.isIncoming) {
const parsedContent = this.stripStyleCharacters(contentToBeParsed);
if (parsedContent) {
return parsedContent;

View file

@ -98,7 +98,7 @@ export default {
profiles: additional.social_profiles || {},
city: additional.city || '---',
country: additional.country || '---',
conversations_count: item.conversations_count || '---',
conversationsCount: item.conversations_count || '---',
last_activity_at: lastActivityAt
? this.dynamicTime(lastActivityAt)
: '---',

View file

@ -49,6 +49,7 @@ class Conversation < ApplicationRecord
scope :latest, -> { order(last_activity_at: :desc) }
scope :unassigned, -> { where(assignee_id: nil) }
scope :assigned, -> { where.not(assignee_id: nil) }
scope :assigned_to, ->(agent) { where(assignee_id: agent.id) }
belongs_to :account

View file

@ -1,6 +1,7 @@
json.data do
json.meta do
json.mine_count @conversations_count[:mine_count]
json.assigned_count @conversations_count[:assigned_count]
json.unassigned_count @conversations_count[:unassigned_count]
json.all_count @conversations_count[:all_count]
end

View file

@ -1,5 +1,6 @@
json.meta do
json.mine_count @conversations_count[:mine_count]
json.assigned_count @conversations_count[:assigned_count]
json.unassigned_count @conversations_count[:unassigned_count]
json.all_count @conversations_count[:all_count]
end

View file

@ -1,5 +1,5 @@
shared: &shared
version: '1.18.0'
version: '1.18.1'
development:
<<: *shared

View file

@ -8,7 +8,7 @@ internal_check_new_versions_job:
queue: scheduled_jobs
# executed At every 5th minute..
internal_check_new_versions_job:
trigger_scheduled_items_job:
cron: "*/5 * * * *"
class: "TriggerScheduledItemsJob"
queue: scheduled_jobs

View file

@ -1,6 +1,6 @@
{
"name": "@chatwoot/chatwoot",
"version": "1.18.0",
"version": "1.18.1",
"license": "MIT",
"scripts": {
"eslint": "eslint app/javascript --fix",

View file

@ -29,6 +29,7 @@ RSpec.describe 'Conversations API', type: :request do
expect(response).to have_http_status(:success)
body = JSON.parse(response.body, symbolize_names: true)
expect(body[:data][:meta][:all_count]).to eq(1)
expect(body[:data][:meta].keys).to include(:all_count, :mine_count, :assigned_count, :unassigned_count)
expect(body[:data][:payload].first[:messages].first[:id]).to eq(message.id)
end
@ -68,7 +69,9 @@ RSpec.describe 'Conversations API', type: :request do
as: :json
expect(response).to have_http_status(:success)
expect(JSON.parse(response.body, symbolize_names: true)[:meta][:all_count]).to eq(1)
body = JSON.parse(response.body, symbolize_names: true)
expect(body[:meta].keys).to include(:all_count, :mine_count, :assigned_count, :unassigned_count)
expect(body[:meta][:all_count]).to eq(1)
end
end
end

View file

@ -55,6 +55,16 @@ describe ::ConversationFinder do
result = conversation_finder.perform
expect(result[:conversations].count).to be 3
end
it 'returns the correct meta' do
result = conversation_finder.perform
expect(result[:count]).to eq({
mine_count: 2,
assigned_count: 3,
unassigned_count: 1,
all_count: 4
})
end
end
context 'with team' do