helpscout: use replies_sent to compute contact rate
The `conversations_count` we previously used counts replies, but also all conversations that were tagged or re-tagged during the month – with made counting the actual work spent on user support brittle. Counting the replies is a better estimation of what we get. Unfortunately this also removes the filtering-by-tag feature. To mitigate this, the reports are now scoped to a specific mailbox. This allows to create extra mailboxes for conversations that should't be counted in the stats.
This commit is contained in:
parent
52226804d0
commit
503c393a87
6 changed files with 57 additions and 62 deletions
|
@ -15,9 +15,7 @@ describe Helpscout::UserConversationsAdapter do
|
|||
|
||||
context 'when all required secrets are present' do
|
||||
before do
|
||||
Rails.application.secrets.helpscout[:mailbox_id] = '9999'
|
||||
Rails.application.secrets.helpscout[:client_id] = '1234'
|
||||
Rails.application.secrets.helpscout[:client_secret] = '5678'
|
||||
mock_helpscout_secrets
|
||||
end
|
||||
|
||||
it { expect(described_class.new(from, to).can_fetch_reports?).to be true }
|
||||
|
@ -25,7 +23,10 @@ describe Helpscout::UserConversationsAdapter do
|
|||
end
|
||||
|
||||
describe '#reports', vcr: { cassette_name: 'helpscout_conversations_reports' } do
|
||||
before { Rails.cache.clear }
|
||||
before do
|
||||
mock_helpscout_secrets
|
||||
Rails.cache.clear
|
||||
end
|
||||
|
||||
subject { described_class.new(from, to) }
|
||||
|
||||
|
@ -34,13 +35,19 @@ describe Helpscout::UserConversationsAdapter do
|
|||
end
|
||||
|
||||
it 'populates each report with data' do
|
||||
expect(subject.reports.first[:conversations_count]).to be > 0
|
||||
expect(subject.reports.first[:replies_sent]).to be > 0
|
||||
expect(subject.reports.first[:start_date]).to eq Time.utc(2017, 11)
|
||||
expect(subject.reports.first[:end_date]).to eq Time.utc(2017, 12)
|
||||
|
||||
expect(subject.reports.last[:conversations_count]).to be > 0
|
||||
expect(subject.reports.last[:replies_sent]).to be > 0
|
||||
expect(subject.reports.last[:start_date]).to eq Time.utc(2017, 12)
|
||||
expect(subject.reports.last[:end_date]).to eq Time.utc(2018, 01)
|
||||
end
|
||||
end
|
||||
|
||||
def mock_helpscout_secrets
|
||||
Rails.application.secrets.helpscout[:mailbox_id] = '9999'
|
||||
Rails.application.secrets.helpscout[:client_id] = '1234'
|
||||
Rails.application.secrets.helpscout[:client_secret] = '5678'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue