Commit 7d144dc0 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'service_desk_usage_ping' into 'master'

Service desk usage ping

Closes #1706

See merge request !1588
parents ce0fb87c cb4a9f8a
...@@ -74,9 +74,11 @@ The total number of the following is sent back to GitLab Inc.: ...@@ -74,9 +74,11 @@ The total number of the following is sent back to GitLab Inc.:
- Protected branches - Protected branches
- Releases - Releases
- Remote mirrors - Remote mirrors
- Service Desk projects
- Service Desk issues
- Web hooks - 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"`. For example: `"mattermost_enabled":true"`.
## Privacy policy ## Privacy policy
......
...@@ -49,7 +49,20 @@ module Gitlab ...@@ -49,7 +49,20 @@ module Gitlab
todos: Todo.count, todos: Todo.count,
uploads: Upload.count, uploads: Upload.count,
web_hooks: WebHook.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 end
......
require 'spec_helper' require 'spec_helper'
describe Gitlab::UsageData do describe Gitlab::UsageData do
let!(:project) { create(:project) } let!(:project) { create(:empty_project) }
let!(:project2) { create(:project) } let!(:project2) { create(:empty_project) }
let!(:board) { create(:board, project: project) } let!(:board) { create(:board, project: project) }
describe '#data' do describe '#data' do
subject { Gitlab::UsageData.data } subject { described_class.data }
it "gathers usage data" do it "gathers usage data" do
expect(subject.keys).to match_array(%i( expect(subject.keys).to match_array(%i(
...@@ -68,8 +68,8 @@ describe Gitlab::UsageData do ...@@ -68,8 +68,8 @@ describe Gitlab::UsageData do
end end
end end
describe '#license_usage_data' do describe '.license_usage_data' do
subject { Gitlab::UsageData.license_usage_data } subject { described_class.license_usage_data }
it "gathers license data" do it "gathers license data" do
license = ::License.current license = ::License.current
...@@ -87,4 +87,29 @@ describe Gitlab::UsageData do ...@@ -87,4 +87,29 @@ describe Gitlab::UsageData do
expect(subject[:recorded_at]).to be_a(Time) expect(subject[:recorded_at]).to be_a(Time)
end end
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 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