Commit cb4a9f8a authored by Felipe Artur's avatar Felipe Artur Committed by Sean McGivern

Retrieve service desk usage from instances

parent 0e519d55
......@@ -74,9 +74,11 @@ The total number of the following is sent back to GitLab Inc.:
- Protected branches
- Releases
- Remote mirrors
- Service Desk projects
- Service Desk issues
- Web hooks
Also, we track if you've installed Mattermost with GitLab.
Also, we track if you've installed Mattermost with GitLab.
For example: `"mattermost_enabled":true"`.
## Privacy policy
......
......@@ -49,7 +49,20 @@ module Gitlab
todos: Todo.count,
uploads: Upload.count,
web_hooks: WebHook.count
}
}.merge(service_desk_counts)
}
end
def service_desk_counts
return {} unless ::License.current.add_on?('GitLab_ServiceDesk')
projects_with_service_desk = Project.where(service_desk_enabled: true)
{
service_desk_enabled_projects: projects_with_service_desk.count,
service_desk_issues: Issue.where(project: projects_with_service_desk,
author: User.support_bot,
confidential: true).count
}
end
......
require 'spec_helper'
describe Gitlab::UsageData do
let!(:project) { create(:project) }
let!(:project2) { create(:project) }
let!(:project) { create(:empty_project) }
let!(:project2) { create(:empty_project) }
let!(:board) { create(:board, project: project) }
describe '#data' do
subject { Gitlab::UsageData.data }
subject { described_class.data }
it "gathers usage data" do
expect(subject.keys).to match_array(%i(
......@@ -68,8 +68,8 @@ describe Gitlab::UsageData do
end
end
describe '#license_usage_data' do
subject { Gitlab::UsageData.license_usage_data }
describe '.license_usage_data' do
subject { described_class.license_usage_data }
it "gathers license data" do
license = ::License.current
......@@ -87,4 +87,29 @@ describe Gitlab::UsageData do
expect(subject[:recorded_at]).to be_a(Time)
end
end
describe '.service_desk_counts' do
subject { described_class.service_desk_counts }
let!(:project3) { create(:empty_project, service_desk_enabled: true) }
let!(:project4) { create(:empty_project, service_desk_enabled: true) }
context 'when Service Desk is disabled' do
it 'returns an empty hash' do
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk').and_return(false)
expect(subject).to eq({})
end
end
context 'when Service Desk is enabled' do
it 'gathers Service Desk data' do
create_list(:issue, 3, confidential: true, author: User.support_bot, project: [project3, project4].sample)
allow_any_instance_of(License).to receive(:add_on?).with('GitLab_ServiceDesk').and_return(true)
expect(subject).to eq(service_desk_enabled_projects: 2,
service_desk_issues: 3)
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment