feat: Add Reports for teams (#3116)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Fayaz Ahmed
2021-10-06 23:53:51 +05:30
committed by GitHub
parent 3e99088fe3
commit 1c6a539c0a
15 changed files with 240 additions and 59 deletions

View File

@@ -171,14 +171,14 @@ describe ::V2::ReportBuilder do
type: :label,
id: label_1.id,
since: (Time.zone.today - 3.days).to_time.to_i.to_s,
until: Time.zone.today.to_time.to_i.to_s
until: (Time.zone.today + 1.day).to_time.to_i.to_s
}
builder = V2::ReportBuilder.new(account, params)
metrics = builder.timeseries
expect(metrics[Time.zone.today]).to be 20
expect(metrics[Time.zone.today - 2.days]).to be 5
expect(metrics[Time.zone.today - 2.days]).to be 0
end
it 'return outgoing messages count' do
@@ -187,14 +187,14 @@ describe ::V2::ReportBuilder do
type: :label,
id: label_1.id,
since: (Time.zone.today - 3.days).to_time.to_i.to_s,
until: Time.zone.today.to_time.to_i.to_s
until: (Time.zone.today + 1.day).to_time.to_i.to_s
}
builder = V2::ReportBuilder.new(account, params)
metrics = builder.timeseries
expect(metrics[Time.zone.today]).to be 50
expect(metrics[Time.zone.today - 2.days]).to be 15
expect(metrics[Time.zone.today - 2.days]).to be 0
end
it 'return resolutions count' do
@@ -203,7 +203,7 @@ describe ::V2::ReportBuilder do
type: :label,
id: label_2.id,
since: (Time.zone.today - 3.days).to_time.to_i.to_s,
until: Time.zone.today.to_time.to_i.to_s
until: (Time.zone.today + 1.day).to_time.to_i.to_s
}
conversations = account.conversations.where('created_at < ?', 1.day.ago)
@@ -242,8 +242,8 @@ describe ::V2::ReportBuilder do
metrics = builder.summary
expect(metrics[:conversations_count]).to be 5
expect(metrics[:incoming_messages_count]).to be 25
expect(metrics[:outgoing_messages_count]).to be 65
expect(metrics[:incoming_messages_count]).to be 5
expect(metrics[:outgoing_messages_count]).to be 15
expect(metrics[:avg_resolution_time]).to be 0
expect(metrics[:resolutions_count]).to be 0
end