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
Boxiang Sun
gitlab-ce
Commits
124ef7dd
Commit
124ef7dd
authored
Jul 19, 2017
by
Jarka Kadlecova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Slack and JIRA services counts to Usage Data
parent
b92d5135
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
6 deletions
+42
-6
changelogs/unreleased/31533-usage-data-projects-stats.yml
changelogs/unreleased/31533-usage-data-projects-stats.yml
+4
-0
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+13
-2
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+25
-4
No files found.
changelogs/unreleased/31533-usage-data-projects-stats.yml
0 → 100644
View file @
124ef7dd
---
title
:
Add Slack and JIRA services counts to Usage Data
merge_request
:
author
:
lib/gitlab/usage_data.rb
View file @
124ef7dd
...
@@ -40,14 +40,13 @@ module Gitlab
...
@@ -40,14 +40,13 @@ module Gitlab
pages_domains:
PagesDomain
.
count
,
pages_domains:
PagesDomain
.
count
,
projects:
Project
.
count
,
projects:
Project
.
count
,
projects_imported_from_github:
Project
.
where
(
import_type:
'github'
).
count
,
projects_imported_from_github:
Project
.
where
(
import_type:
'github'
).
count
,
projects_prometheus_active:
PrometheusService
.
active
.
count
,
protected_branches:
ProtectedBranch
.
count
,
protected_branches:
ProtectedBranch
.
count
,
releases:
Release
.
count
,
releases:
Release
.
count
,
snippets:
Snippet
.
count
,
snippets:
Snippet
.
count
,
todos:
Todo
.
count
,
todos:
Todo
.
count
,
uploads:
Upload
.
count
,
uploads:
Upload
.
count
,
web_hooks:
WebHook
.
count
web_hooks:
WebHook
.
count
}
}
.
merge
(
services_usage
)
}
}
end
end
...
@@ -64,6 +63,18 @@ module Gitlab
...
@@ -64,6 +63,18 @@ module Gitlab
usage_data
usage_data
end
end
def
services_usage
types
=
{
JiraService
:
:projects_jira_active
,
SlackService
:
:projects_slack_notifications_active
,
SlackSlashCommandsService
:
:projects_slack_slash_active
,
PrometheusService
:
:projects_prometheus_active
}
results
=
Service
.
unscoped
.
where
(
type:
types
.
keys
,
active:
true
).
group
(
:type
).
count
results
.
each_with_object
({})
{
|
(
key
,
value
),
response
|
response
[
types
[
key
.
to_sym
]]
=
value
}
end
end
end
end
end
end
end
spec/lib/gitlab/usage_data_spec.rb
View file @
124ef7dd
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
UsageData
do
describe
Gitlab
::
UsageData
do
let!
(
:project
)
{
create
(
:empty_project
)
}
let
(
:projects
)
{
create_list
(
:project
,
3
)
}
let!
(
:project2
)
{
create
(
:empty_project
)
}
let!
(
:board
)
{
create
(
:board
,
project:
projects
[
0
])
}
let!
(
:board
)
{
create
(
:board
,
project:
project
)
}
describe
'#data'
do
describe
'#data'
do
before
do
create
(
:jira_service
,
project:
projects
[
0
])
create
(
:jira_service
,
project:
projects
[
1
])
create
(
:prometheus_service
,
project:
projects
[
1
])
create
(
:service
,
project:
projects
[
0
],
type:
'SlackSlashCommandsService'
,
active:
true
)
create
(
:service
,
project:
projects
[
1
],
type:
'SlackService'
,
active:
true
)
create
(
:service
,
project:
projects
[
2
],
type:
'SlackService'
,
active:
true
)
end
subject
{
described_class
.
data
}
subject
{
described_class
.
data
}
it
"gathers usage data"
do
it
"gathers usage data"
do
...
@@ -25,7 +33,7 @@ describe Gitlab::UsageData do
...
@@ -25,7 +33,7 @@ describe Gitlab::UsageData do
count_data
=
subject
[
:counts
]
count_data
=
subject
[
:counts
]
expect
(
count_data
[
:boards
]).
to
eq
(
1
)
expect
(
count_data
[
:boards
]).
to
eq
(
1
)
expect
(
count_data
[
:projects
]).
to
eq
(
2
)
expect
(
count_data
[
:projects
]).
to
eq
(
3
)
expect
(
count_data
.
keys
).
to
match_array
(
%i(
expect
(
count_data
.
keys
).
to
match_array
(
%i(
boards
boards
...
@@ -49,6 +57,9 @@ describe Gitlab::UsageData do
...
@@ -49,6 +57,9 @@ describe Gitlab::UsageData do
notes
notes
projects
projects
projects_imported_from_github
projects_imported_from_github
projects_jira_active
projects_slack_notifications_active
projects_slack_slash_active
projects_prometheus_active
projects_prometheus_active
pages_domains
pages_domains
protected_branches
protected_branches
...
@@ -59,6 +70,16 @@ describe Gitlab::UsageData do
...
@@ -59,6 +70,16 @@ describe Gitlab::UsageData do
web_hooks
web_hooks
)
)
)
)
end
end
it
'gathers projects data correctly'
do
count_data
=
subject
[
:counts
]
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_slack_notifications_active
]).
to
eq
(
2
)
expect
(
count_data
[
:projects_slack_slash_active
]).
to
eq
(
1
)
end
end
end
describe
'#license_usage_data'
do
describe
'#license_usage_data'
do
...
...
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