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
69179973
Commit
69179973
authored
Dec 03, 2021
by
Adam Hegyi
Committed by
Vitali Tatarintev
Dec 03, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use aggregated VSA backend in time summary
parent
70667ba9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
5 deletions
+63
-5
app/controllers/concerns/cycle_analytics_params.rb
app/controllers/concerns/cycle_analytics_params.rb
+1
-0
ee/lib/gitlab/analytics/cycle_analytics/summary/base_time.rb
ee/lib/gitlab/analytics/cycle_analytics/summary/base_time.rb
+14
-3
ee/spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb
...ects/analytics/cycle_analytics/summary_controller_spec.rb
+19
-2
ee/spec/lib/gitlab/analytics/cycle_analytics/summary/stage_time_summary_spec.rb
...lytics/cycle_analytics/summary/stage_time_summary_spec.rb
+29
-0
No files found.
app/controllers/concerns/cycle_analytics_params.rb
View file @
69179973
...
...
@@ -23,6 +23,7 @@ module CycleAnalyticsParams
opts
[
:from
]
=
params
[
:from
]
||
start_date
(
params
)
opts
[
:to
]
=
params
[
:to
]
if
params
[
:to
]
opts
[
:end_event_filter
]
=
params
[
:end_event_filter
]
if
params
[
:end_event_filter
]
opts
[
:use_aggregated_data_collector
]
=
params
[
:use_aggregated_data_collector
]
if
params
[
:use_aggregated_data_collector
]
opts
.
merge!
(
params
.
slice
(
*::
Gitlab
::
Analytics
::
CycleAnalytics
::
RequestParams
::
FINDER_PARAM_NAMES
))
opts
.
merge!
(
date_range
(
params
))
end
...
...
ee/lib/gitlab/analytics/cycle_analytics/summary/base_time.rb
View file @
69179973
...
...
@@ -10,7 +10,7 @@ module Gitlab
@current_user
=
current_user
@options
=
options
assign_
event_identifiers
assign_
stage_metadata
end
def
value
...
...
@@ -35,10 +35,20 @@ module Gitlab
private
def
assign_event_identifiers
# rubocop: disable CodeReuse/ActiveRecord
def
assign_stage_metadata
@stage
.
start_event_identifier
=
self
.
class
.
start_event_identifier
@stage
.
end_event_identifier
=
self
.
class
.
end_event_identifier
if
@options
[
:use_aggregated_data_collector
]
# Gitlab::Analytics::CycleAnalytics::DistinctStageLoader ensures that we have StageEventHash record
# for the subclasses (LeadTime, CycleTime) however, it is an asynchronous process. There can be a short period
# of time where the query below returns nil. To handle this, we're pre-setting "None" value.
@stage
.
stage_event_hash_id
=
::
Analytics
::
CycleAnalytics
::
StageEventHash
.
find_by
(
hash_sha256:
@stage
.
events_hash_code
)
&
.
id
@value
=
Gitlab
::
CycleAnalytics
::
Summary
::
Value
::
None
.
new
if
@stage
.
stage_event_hash_id
.
blank?
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
data_collector
Gitlab
::
Analytics
::
CycleAnalytics
::
DataCollector
.
new
(
...
...
@@ -48,7 +58,8 @@ module Gitlab
to:
@options
[
:to
]
||
DateTime
.
now
,
project_ids:
@options
[
:projects
],
end_event_filter:
@options
[
:end_event_filter
],
current_user:
@current_user
current_user:
@current_user
,
use_aggregated_data_collector:
@options
[
:use_aggregated_data_collector
]
}.
merge
(
@options
.
slice
(
*::
Gitlab
::
Analytics
::
CycleAnalytics
::
RequestParams
::
FINDER_PARAM_NAMES
))
)
end
...
...
ee/spec/controllers/projects/analytics/cycle_analytics/summary_controller_spec.rb
View file @
69179973
...
...
@@ -4,7 +4,8 @@ require 'spec_helper'
RSpec
.
describe
Projects
::
Analytics
::
CycleAnalytics
::
SummaryController
do
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
group:
group
)
}
let
(
:params
)
{
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
created_after:
'2010-01-01'
,
created_before:
'2020-01-02'
}
}
...
...
@@ -26,7 +27,9 @@ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do
context
'when cycle_analytics_for_projects feature is available'
do
before
do
stub_licensed_features
(
cycle_analytics_for_projects:
true
)
stub_licensed_features
(
cycle_analytics_for_projects:
true
,
cycle_analytics_for_groups:
true
)
Analytics
::
CycleAnalytics
::
GroupDataLoaderWorker
.
new
.
perform
(
group
.
id
,
'Issue'
)
project
.
add_reporter
(
user
)
end
...
...
@@ -45,6 +48,20 @@ RSpec.describe Projects::Analytics::CycleAnalytics::SummaryController do
expect
(
json_response
.
last
[
"value"
].
to_i
).
to
eq
(
expected_cycle_time
)
end
context
'when the use_vsa_aggregated_tables FF is off'
do
before
do
stub_feature_flags
(
use_vsa_aggregated_tables:
false
)
end
it
'returns correct value'
do
expected_cycle_time
=
(
closed_at
-
first_mentioned_in_commit_at
).
to_i
subject
expect
(
json_response
.
last
[
"value"
].
to_i
).
to
eq
(
expected_cycle_time
)
end
end
context
'when analytics_disabled features are disabled'
do
it
'renders 404'
do
project
.
add_reporter
(
user
)
...
...
ee/spec/lib/gitlab/analytics/cycle_analytics/summary/stage_time_summary_spec.rb
View file @
69179973
...
...
@@ -23,6 +23,35 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Summary::StageTimeSummary do
group
.
add_owner
(
user
)
end
context
'when the use_aggregated_data_collector option is given'
do
context
'when aggregated data is available yet'
do
it
'shows no value'
do
lead_time
,
cycle_time
,
*
=
subject
expect
(
lead_time
[
:value
]).
to
eq
(
'-'
)
expect
(
cycle_time
[
:value
]).
to
eq
(
'-'
)
end
end
context
'when aggregated data is present'
do
before
do
issue
=
create
(
:closed_issue
,
project:
project
,
created_at:
1
.
day
.
ago
,
closed_at:
Time
.
current
)
issue
.
metrics
.
update!
(
first_mentioned_in_commit_at:
2
.
days
.
ago
)
options
[
:use_aggregated_data_collector
]
=
true
stub_licensed_features
(
cycle_analytics_for_groups:
true
)
Analytics
::
CycleAnalytics
::
GroupDataLoaderWorker
.
new
.
perform
(
group
.
id
,
'Issue'
)
end
it
'loads the lead and cycle time'
do
lead_time
,
cycle_time
,
*
=
subject
expect
(
lead_time
[
:value
]).
to
eq
(
'1.0'
)
expect
(
cycle_time
[
:value
]).
to
eq
(
'2.0'
)
end
end
end
describe
'#lead_time'
do
describe
'issuable filter parameters'
do
let_it_be
(
:label
)
{
create
(
:group_label
,
group:
group
)
}
...
...
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