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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
e54f976f
Commit
e54f976f
authored
Jul 23, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
5556c76d
5032df86
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
118 additions
and
43 deletions
+118
-43
app/models/cycle_analytics/group_level.rb
app/models/cycle_analytics/group_level.rb
+1
-3
changelogs/unreleased/adjust-group-level-analytics-to-accept-multiple-ids.yml
...d/adjust-group-level-analytics-to-accept-multiple-ids.yml
+5
-0
lib/gitlab/cycle_analytics/base_event_fetcher.rb
lib/gitlab/cycle_analytics/base_event_fetcher.rb
+1
-12
lib/gitlab/cycle_analytics/base_stage.rb
lib/gitlab/cycle_analytics/base_stage.rb
+1
-12
lib/gitlab/cycle_analytics/group_projects_provider.rb
lib/gitlab/cycle_analytics/group_projects_provider.rb
+27
-0
lib/gitlab/cycle_analytics/group_stage_summary.rb
lib/gitlab/cycle_analytics/group_stage_summary.rb
+8
-5
lib/gitlab/cycle_analytics/summary/group/base.rb
lib/gitlab/cycle_analytics/summary/group/base.rb
+4
-1
lib/gitlab/cycle_analytics/summary/group/deploy.rb
lib/gitlab/cycle_analytics/summary/group/deploy.rb
+8
-7
lib/gitlab/cycle_analytics/summary/group/issue.rb
lib/gitlab/cycle_analytics/summary/group/issue.rb
+13
-2
spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
+27
-1
spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
+23
-0
No files found.
app/models/cycle_analytics/group_level.rb
View file @
e54f976f
...
...
@@ -11,9 +11,7 @@ module CycleAnalytics
end
def
summary
@summary
||=
::
Gitlab
::
CycleAnalytics
::
GroupStageSummary
.
new
(
group
,
from:
options
[
:from
],
current_user:
options
[
:current_user
]).
data
@summary
||=
::
Gitlab
::
CycleAnalytics
::
GroupStageSummary
.
new
(
group
,
options:
options
).
data
end
def
permissions
(
*
)
...
...
changelogs/unreleased/adjust-group-level-analytics-to-accept-multiple-ids.yml
0 → 100644
View file @
e54f976f
---
title
:
Adjust group level analytics to accept multiple ids
merge_request
:
30744
author
:
type
:
added
lib/gitlab/cycle_analytics/base_event_fetcher.rb
View file @
e54f976f
...
...
@@ -4,6 +4,7 @@ module Gitlab
module
CycleAnalytics
class
BaseEventFetcher
include
BaseQuery
include
GroupProjectsProvider
attr_reader
:projections
,
:query
,
:stage
,
:order
,
:options
...
...
@@ -73,18 +74,6 @@ module Gitlab
def
serialization_context
{}
end
def
projects
group
?
Project
.
inside_path
(
group
.
full_path
)
:
[
project
]
end
def
group
@group
||=
options
.
fetch
(
:group
,
nil
)
end
def
project
@project
||=
options
.
fetch
(
:project
,
nil
)
end
end
end
end
lib/gitlab/cycle_analytics/base_stage.rb
View file @
e54f976f
...
...
@@ -4,6 +4,7 @@ module Gitlab
module
CycleAnalytics
class
BaseStage
include
BaseQuery
include
GroupProjectsProvider
attr_reader
:options
...
...
@@ -77,18 +78,6 @@ module Gitlab
def
event_options
options
.
merge
(
start_time_attrs:
start_time_attrs
,
end_time_attrs:
end_time_attrs
)
end
def
projects
group
?
Project
.
inside_path
(
group
.
full_path
)
:
[
project
]
end
def
group
@group
||=
options
.
fetch
(
:group
,
nil
)
end
def
project
@project
||=
options
.
fetch
(
:project
,
nil
)
end
end
end
end
lib/gitlab/cycle_analytics/group_projects_provider.rb
0 → 100644
View file @
e54f976f
# frozen_string_literal: true
module
Gitlab
module
CycleAnalytics
module
GroupProjectsProvider
def
projects
group
?
projects_for_group
:
[
project
]
end
def
group
@group
||=
options
.
fetch
(
:group
,
nil
)
end
def
project
@project
||=
options
.
fetch
(
:project
,
nil
)
end
private
def
projects_for_group
projects
=
Project
.
inside_path
(
group
.
full_path
)
projects
=
projects
.
where
(
id:
options
[
:projects
])
if
options
[
:projects
]
projects
end
end
end
end
lib/gitlab/cycle_analytics/group_stage_summary.rb
View file @
e54f976f
...
...
@@ -3,15 +3,18 @@
module
Gitlab
module
CycleAnalytics
class
GroupStageSummary
def
initialize
(
group
,
from
:,
current_user
:)
attr_reader
:group
,
:from
,
:current_user
,
:options
def
initialize
(
group
,
options
:)
@group
=
group
@from
=
from
@current_user
=
current_user
@from
=
options
[
:from
]
@current_user
=
options
[
:current_user
]
@options
=
options
end
def
data
[
serialize
(
Summary
::
Group
::
Issue
.
new
(
group:
@group
,
from:
@from
,
current_user:
@current_user
)),
serialize
(
Summary
::
Group
::
Deploy
.
new
(
group:
@group
,
from:
@from
))]
[
serialize
(
Summary
::
Group
::
Issue
.
new
(
group:
group
,
from:
from
,
current_user:
current_user
,
options:
options
)),
serialize
(
Summary
::
Group
::
Deploy
.
new
(
group:
group
,
from:
from
,
options:
options
))]
end
private
...
...
lib/gitlab/cycle_analytics/summary/group/base.rb
View file @
e54f976f
...
...
@@ -5,9 +5,12 @@ module Gitlab
module
Summary
module
Group
class
Base
def
initialize
(
group
:,
from
:)
attr_reader
:group
,
:from
,
:options
def
initialize
(
group
:,
from
:,
options
:)
@group
=
group
@from
=
from
@options
=
options
end
def
title
...
...
lib/gitlab/cycle_analytics/summary/group/deploy.rb
View file @
e54f976f
...
...
@@ -5,22 +5,23 @@ module Gitlab
module
Summary
module
Group
class
Deploy
<
Group
::
Base
include
GroupProjectsProvider
def
title
n_
(
'Deploy'
,
'Deploys'
,
value
)
end
def
value
@value
||=
Deployment
.
joins
(
:project
)
.
where
(
projects:
{
id:
projects
})
.
where
(
"deployments.created_at > ?"
,
@from
)
.
success
.
count
@value
||=
find_deployments
end
private
def
projects
Project
.
inside_path
(
@group
.
full_path
).
ids
def
find_deployments
deployments
=
Deployment
.
joins
(
:project
).
merge
(
Project
.
inside_path
(
group
.
full_path
))
deployments
=
deployments
.
where
(
projects:
{
id:
options
[
:projects
]
})
if
options
[
:projects
]
deployments
=
deployments
.
where
(
"deployments.created_at > ?"
,
from
)
deployments
.
success
.
count
end
end
end
...
...
lib/gitlab/cycle_analytics/summary/group/issue.rb
View file @
e54f976f
...
...
@@ -5,10 +5,13 @@ module Gitlab
module
Summary
module
Group
class
Issue
<
Group
::
Base
def
initialize
(
group
:,
from
:,
current_user
:)
attr_reader
:group
,
:from
,
:current_user
,
:options
def
initialize
(
group
:,
from
:,
current_user
:,
options
:)
@group
=
group
@from
=
from
@current_user
=
current_user
@options
=
options
end
def
title
...
...
@@ -16,7 +19,15 @@ module Gitlab
end
def
value
@value
||=
IssuesFinder
.
new
(
@current_user
,
group_id:
@group
.
id
,
include_subgroups:
true
,
created_after:
@from
).
execute
.
count
@value
||=
find_issues
end
private
def
find_issues
issues
=
IssuesFinder
.
new
(
current_user
,
group_id:
group
.
id
,
include_subgroups:
true
,
created_after:
from
).
execute
issues
=
issues
.
where
(
projects:
{
id:
options
[
:projects
]
})
if
options
[
:projects
]
issues
.
count
end
end
end
...
...
spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
View file @
e54f976f
...
...
@@ -8,7 +8,7 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
let
(
:from
)
{
1
.
day
.
ago
}
let
(
:user
)
{
create
(
:user
,
:admin
)
}
subject
{
described_class
.
new
(
group
,
from:
Time
.
now
,
current_user:
user
).
data
}
subject
{
described_class
.
new
(
group
,
options:
{
from:
Time
.
now
,
current_user:
user
}
).
data
}
describe
"#new_issues"
do
context
'with from date'
do
...
...
@@ -32,6 +32,18 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
expect
(
subject
.
first
[
:value
]).
to
eq
(
3
)
end
end
context
'with projects specified in options'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
{
create
(
:issue
,
project:
create
(
:project
,
namespace:
group
))
}
end
subject
{
described_class
.
new
(
group
,
options:
{
from:
Time
.
now
,
current_user:
user
,
projects:
[
project
.
id
,
project_2
.
id
]
}).
data
}
it
'finds issues from those projects'
do
expect
(
subject
.
first
[
:value
]).
to
eq
(
2
)
end
end
end
context
'with other projects'
do
...
...
@@ -71,6 +83,20 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
expect
(
subject
.
second
[
:value
]).
to
eq
(
3
)
end
end
context
'with projects specified in options'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
do
create
(
:deployment
,
:success
,
project:
create
(
:project
,
:repository
,
namespace:
group
,
name:
'not_applicable'
))
end
end
subject
{
described_class
.
new
(
group
,
options:
{
from:
Time
.
now
,
current_user:
user
,
projects:
[
project
.
id
,
project_2
.
id
]
}).
data
}
it
'shows deploys from those projects'
do
expect
(
subject
.
second
[
:value
]).
to
eq
(
2
)
end
end
end
context
'with other projects'
do
...
...
spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
View file @
e54f976f
...
...
@@ -71,6 +71,29 @@ describe Gitlab::CycleAnalytics::IssueStage do
end
end
context
'when only part of projects is chosen'
do
let
(
:stage
)
{
described_class
.
new
(
options:
{
from:
2
.
days
.
ago
,
current_user:
user
,
group:
group
,
projects:
[
project_2
.
id
]
})
}
describe
'#group_median'
do
around
do
|
example
|
Timecop
.
freeze
{
example
.
run
}
end
it
'counts median from issues with metrics'
do
expect
(
stage
.
group_median
).
to
eq
(
ISSUES_MEDIAN
)
end
end
describe
'#events'
do
subject
{
stage
.
events
}
it
'exposes merge requests that close issues'
do
expect
(
subject
.
count
).
to
eq
(
1
)
expect
(
subject
.
map
{
|
event
|
event
[
:title
]
}).
to
contain_exactly
(
issue_2_1
.
title
)
end
end
end
context
'when subgroup is given'
do
let
(
:subgroup
)
{
create
(
:group
,
parent:
group
)
}
let
(
:project_4
)
{
create
(
:project
,
group:
subgroup
)
}
...
...
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