Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
013d097e
Commit
013d097e
authored
Nov 03, 2018
by
Mario de la Ossa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Usage ping - Differentiate Jira Server and Cloud
parent
f5d71ad8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
+34
-2
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+17
-1
spec/factories/services.rb
spec/factories/services.rb
+11
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+6
-1
No files found.
lib/gitlab/usage_data.rb
View file @
013d097e
...
...
@@ -126,7 +126,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
...
...
@@ -134,6 +133,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
)
...
...
spec/factories/services.rb
View file @
013d097e
...
...
@@ -46,6 +46,17 @@ FactoryBot.define do
)
end
factory
:jira_cloud_service
,
class:
JiraService
do
project
active
true
properties
(
url:
'https://mysite.atlassian.net'
,
username:
'jira_user'
,
password:
'my-secret-password'
,
project_key:
'jira-key'
)
end
factory
:hipchat_service
do
project
type
'HipchatService'
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
013d097e
...
...
@@ -8,6 +8,7 @@ describe Gitlab::UsageData do
before
do
create
(
:jira_service
,
project:
projects
[
0
])
create
(
:jira_service
,
project:
projects
[
1
])
create
(
:jira_cloud_service
,
project:
projects
[
2
])
create
(
:prometheus_service
,
project:
projects
[
1
])
create
(
:service
,
project:
projects
[
0
],
type:
'SlackSlashCommandsService'
,
active:
true
)
create
(
:service
,
project:
projects
[
1
],
type:
'SlackService'
,
active:
true
)
...
...
@@ -95,6 +96,8 @@ describe Gitlab::UsageData do
projects
projects_imported_from_github
projects_jira_active
projects_jira_server_active
projects_jira_cloud_active
projects_slack_notifications_active
projects_slack_slash_active
projects_prometheus_active
...
...
@@ -114,7 +117,9 @@ describe Gitlab::UsageData do
expect
(
count_data
[
:projects
]).
to
eq
(
3
)
expect
(
count_data
[
:projects_prometheus_active
]).
to
eq
(
1
)
expect
(
count_data
[
:projects_jira_active
]).
to
eq
(
2
)
expect
(
count_data
[
:projects_jira_active
]).
to
eq
(
3
)
expect
(
count_data
[
:projects_jira_server_active
]).
to
eq
(
2
)
expect
(
count_data
[
:projects_jira_cloud_active
]).
to
eq
(
1
)
expect
(
count_data
[
:projects_slack_notifications_active
]).
to
eq
(
2
)
expect
(
count_data
[
:projects_slack_slash_active
]).
to
eq
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment