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
18535eb4
Commit
18535eb4
authored
Jul 16, 2019
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add code review remarks
Change small things for better readability
parent
e6c61c89
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
33 deletions
+32
-33
app/models/cycle_analytics/group_level.rb
app/models/cycle_analytics/group_level.rb
+6
-5
app/serializers/group_analytics_stage_entity.rb
app/serializers/group_analytics_stage_entity.rb
+1
-1
lib/gitlab/cycle_analytics/summary/group/issue.rb
lib/gitlab/cycle_analytics/summary/group/issue.rb
+1
-1
spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
+22
-24
spec/models/cycle_analytics/group_level_spec.rb
spec/models/cycle_analytics/group_level_spec.rb
+2
-2
No files found.
app/models/cycle_analytics/group_level.rb
View file @
18535eb4
...
...
@@ -3,19 +3,20 @@
module
CycleAnalytics
class
GroupLevel
include
LevelBase
attr_reader
:options
attr_reader
:options
,
:group
def
initialize
(
options
:)
@options
=
options
def
initialize
(
group
:,
options
:)
@group
=
group
@options
=
options
.
merge
(
group:
group
)
end
def
summary
@summary
||=
::
Gitlab
::
CycleAnalytics
::
GroupStageSummary
.
new
(
options
[
:group
]
,
@summary
||=
::
Gitlab
::
CycleAnalytics
::
GroupStageSummary
.
new
(
group
,
from:
options
[
:from
],
current_user:
options
[
:current_user
]).
data
end
def
permissions
(
user:
nil
)
def
permissions
(
*
)
STAGES
.
each_with_object
({})
do
|
stage
,
obj
|
obj
[
stage
]
=
true
end
...
...
app/serializers/group_analytics_stage_entity.rb
View file @
18535eb4
...
...
@@ -9,7 +9,7 @@ class GroupAnalyticsStageEntity < Grape::Entity
expose
:description
expose
:group_median
,
as: :value
do
|
stage
|
# median returns a BatchLoader instance which we first have to unwrap by using to_f
#
group_
median returns a BatchLoader instance which we first have to unwrap by using to_f
# we use to_f to make sure results below 1 are presented to the end-user
stage
.
group_median
.
to_f
.
nonzero?
?
distance_of_time_in_words
(
stage
.
group_median
)
:
nil
end
...
...
lib/gitlab/cycle_analytics/summary/group/issue.rb
View file @
18535eb4
...
...
@@ -16,7 +16,7 @@ module Gitlab
end
def
value
@value
||=
IssuesFinder
.
new
(
@current_user
,
group_id:
@group
.
id
,
include_subgroups:
true
).
execute
.
created_after
(
@from
)
.
count
@value
||=
IssuesFinder
.
new
(
@current_user
,
group_id:
@group
.
id
,
include_subgroups:
true
,
created_after:
@from
).
execute
.
count
end
end
end
...
...
spec/lib/gitlab/cycle_analytics/group_stage_summary_spec.rb
View file @
18535eb4
...
...
@@ -22,6 +22,16 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
it
"finds the number of issues created after it"
do
expect
(
subject
.
first
[
:value
]).
to
eq
(
2
)
end
context
'with subgroups'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
{
create
(
:issue
,
project:
create
(
:project
,
namespace:
create
(
:group
,
parent:
group
)))
}
end
it
"finds issues from them"
do
expect
(
subject
.
first
[
:value
]).
to
eq
(
3
)
end
end
end
context
'with other projects'
do
...
...
@@ -35,18 +45,6 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
expect
(
subject
.
first
[
:value
]).
to
eq
(
2
)
end
end
context
'with subgroups'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
{
create
(
:issue
,
project:
create
(
:project
,
namespace:
create
(
:group
,
parent:
group
)))
}
Timecop
.
freeze
(
5
.
days
.
from_now
)
{
create
(
:issue
,
project:
project
)
}
Timecop
.
freeze
(
5
.
days
.
from_now
)
{
create
(
:issue
,
project:
project_2
)
}
end
it
"finds issues from them"
do
expect
(
subject
.
first
[
:value
]).
to
eq
(
3
)
end
end
end
describe
"#deploys"
do
...
...
@@ -61,29 +59,29 @@ describe Gitlab::CycleAnalytics::GroupStageSummary do
it
"finds the number of deploys made created after it"
do
expect
(
subject
.
second
[
:value
]).
to
eq
(
2
)
end
end
context
'with other projects'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
do
create
(
:deployment
,
:success
,
project:
create
(
:project
,
:repository
,
namespace:
create
(
:group
)))
context
'with subgroups'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
do
create
(
:deployment
,
:success
,
project:
create
(
:project
,
:repository
,
namespace:
create
(
:group
,
parent:
group
)))
end
end
end
it
"doesn't find deploys from them"
do
expect
(
subject
.
second
[
:value
]).
to
eq
(
0
)
it
"finds deploys from them"
do
expect
(
subject
.
second
[
:value
]).
to
eq
(
3
)
end
end
end
context
'with
subgroup
s'
do
context
'with
other project
s'
do
before
do
Timecop
.
freeze
(
5
.
days
.
from_now
)
do
create
(
:deployment
,
:success
,
project:
create
(
:project
,
:repository
,
namespace:
create
(
:group
,
parent:
group
)))
create
(
:deployment
,
:success
,
project:
create
(
:project
,
:repository
,
namespace:
create
(
:group
)))
end
end
it
"
finds
deploys from them"
do
expect
(
subject
.
second
[
:value
]).
to
eq
(
1
)
it
"
doesn't find
deploys from them"
do
expect
(
subject
.
second
[
:value
]).
to
eq
(
0
)
end
end
end
...
...
spec/models/cycle_analytics/group_level_spec.rb
View file @
18535eb4
...
...
@@ -12,10 +12,10 @@ describe CycleAnalytics::GroupLevel do
let
(
:mr
)
{
create_merge_request_closing_issue
(
user
,
project
,
issue
,
commit_message:
"References
#{
issue
.
to_reference
}
"
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
status:
'created'
,
project:
project
,
ref:
mr
.
source_branch
,
sha:
mr
.
source_branch_sha
,
head_pipeline_of:
mr
)
}
subject
{
described_class
.
new
(
options:
{
from:
from_date
,
group:
group
,
current_user:
user
})
}
subject
{
described_class
.
new
(
group:
group
,
options:
{
from:
from_date
,
current_user:
user
})
}
describe
'#permissions'
do
it
'returns
permission
s'
do
it
'returns
true for all stage
s'
do
expect
(
subject
.
permissions
.
values
.
uniq
).
to
eq
([
true
])
end
end
...
...
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