diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-11-07 23:09:24 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-11-07 23:09:24 +0300 |
commit | cc9e3d09007174d4e0c30ae894c67160dcb72d10 (patch) | |
tree | bcca8d4c048c93aec86240317b97863877cdcf16 /lib/gitlab/usage_data.rb | |
parent | 73b7709a95ebb8eff5452e3344dac7f8d369f77c (diff) | |
parent | 013d097e8bfb74b378e949c951ff55327484b518 (diff) |
Merge branch 'jira-ping-differentiate-cloud' into 'master'
Usage ping - Differentiate Jira Server and Cloud
Closes #51043
See merge request gitlab-org/gitlab-ce!22791
Diffstat (limited to 'lib/gitlab/usage_data.rb')
-rw-r--r-- | lib/gitlab/usage_data.rb | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 4e2c6f7b2c2..069cd1f802a 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -127,7 +127,6 @@ module Gitlab # rubocop: disable CodeReuse/ActiveRecord def services_usage types = { - JiraService: :projects_jira_active, SlackService: :projects_slack_notifications_active, SlackSlashCommandsService: :projects_slack_slash_active, PrometheusService: :projects_prometheus_active @@ -135,6 +134,23 @@ module Gitlab results = count(Service.unscoped.where(type: types.keys, active: true).group(:type), fallback: Hash.new(-1)) types.each_with_object({}) { |(klass, key), response| response[key] = results[klass.to_s] || 0 } + .merge(jira_usage) + end + + def jira_usage + # Jira Cloud does not support custom domains as per https://jira.atlassian.com/browse/CLOUD-6999 + # so we can just check for subdomains of atlassian.net + services = count( + Service.unscoped.where(type: :JiraService, active: true) + .group("CASE WHEN properties LIKE '%.atlassian.net%' THEN 'cloud' ELSE 'server' END"), + fallback: Hash.new(-1) + ) + + { + projects_jira_server_active: services['server'] || 0, + projects_jira_cloud_active: services['cloud'] || 0, + projects_jira_active: services['server'] == -1 ? -1 : services.values.sum + } end def count(relation, fallback: -1) |