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
30d63816
Commit
30d63816
authored
Dec 02, 2021
by
Adam Hegyi
Committed by
Nikola Milojevic
Dec 02, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use EXTRACT(EPOCH) when calculating durations
parent
1d835b16
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
7 deletions
+20
-7
ee/lib/gitlab/analytics/cycle_analytics/aggregated/data_for_duration_chart.rb
...ics/cycle_analytics/aggregated/data_for_duration_chart.rb
+1
-1
lib/gitlab/analytics/cycle_analytics/aggregated/median.rb
lib/gitlab/analytics/cycle_analytics/aggregated/median.rb
+1
-1
lib/gitlab/analytics/cycle_analytics/aggregated/records_fetcher.rb
...b/analytics/cycle_analytics/aggregated/records_fetcher.rb
+1
-1
lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb
...alytics/cycle_analytics/aggregated/stage_query_helpers.rb
+4
-4
spec/lib/gitlab/analytics/cycle_analytics/aggregated/records_fetcher_spec.rb
...lytics/cycle_analytics/aggregated/records_fetcher_spec.rb
+13
-0
No files found.
ee/lib/gitlab/analytics/cycle_analytics/aggregated/data_for_duration_chart.rb
View file @
30d63816
...
...
@@ -17,7 +17,7 @@ module Gitlab
def
average_by_day
@query
.
group
(
date_expression
)
.
select
(
date_expression
.
as
(
'date'
),
duration
.
average
.
as
(
'average_duration_in_seconds'
))
.
select
(
date_expression
.
as
(
'date'
),
duration
_in_seconds
.
average
.
as
(
'average_duration_in_seconds'
))
end
# rubocop: enable CodeReuse/ActiveRecord
...
...
lib/gitlab/analytics/cycle_analytics/aggregated/median.rb
View file @
30d63816
...
...
@@ -15,7 +15,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def
seconds
@query
=
@query
.
select
(
median_duration_in_seconds
.
as
(
'median'
)).
reorder
(
nil
)
@query
=
@query
.
select
(
duration_in_seconds
(
percentile_cont
)
.
as
(
'median'
)).
reorder
(
nil
)
result
=
@query
.
take
||
{}
result
[
'median'
]
||
nil
...
...
lib/gitlab/analytics/cycle_analytics/aggregated/records_fetcher.rb
View file @
30d63816
...
...
@@ -36,7 +36,7 @@ module Gitlab
def
serialized_records
strong_memoize
(
:serialized_records
)
do
records
=
ordered_and_limited_query
.
select
(
stage_event_model
.
arel_table
[
Arel
.
star
],
duration
.
as
(
'total_time'
))
records
=
ordered_and_limited_query
.
select
(
stage_event_model
.
arel_table
[
Arel
.
star
],
duration
_in_seconds
.
as
(
'total_time'
))
yield
records
if
block_given?
issuables_and_records
=
load_issuables
(
records
)
...
...
lib/gitlab/analytics/cycle_analytics/aggregated/stage_query_helpers.rb
View file @
30d63816
...
...
@@ -27,13 +27,13 @@ module Gitlab
end
end
def
median_duration_in_seconds
Arel
::
Nodes
::
Extract
.
new
(
percentile_cont
,
:epoch
)
end
def
in_progress?
params
[
:end_event_filter
]
==
:in_progress
end
def
duration_in_seconds
(
duration_expression
=
duration
)
Arel
::
Nodes
::
Extract
.
new
(
duration_expression
,
:epoch
)
end
end
end
end
...
...
spec/lib/gitlab/analytics/cycle_analytics/aggregated/records_fetcher_spec.rb
View file @
30d63816
...
...
@@ -41,6 +41,19 @@ RSpec.describe Gitlab::Analytics::CycleAnalytics::Aggregated::RecordsFetcher do
it_behaves_like
'match returned records'
end
context
'when intervalstyle setting is configured to "postgres"'
do
it
'avoids nil durations'
do
# ActiveRecord cannot parse the 'postgres' intervalstyle, it returns nil
# The setting is rolled back after the test case.
Analytics
::
CycleAnalytics
::
IssueStageEvent
.
connection
.
execute
(
"SET LOCAL intervalstyle='postgres'"
)
records_fetcher
.
serialized_records
do
|
relation
|
durations
=
relation
.
map
(
&
:total_time
)
expect
(
durations
).
to
all
(
be
>
0
)
end
end
end
context
'when sorting by end event ASC'
do
let
(
:expected_issue_ids
)
{
[
issue_2
.
iid
,
issue_1
.
iid
,
issue_3
.
iid
]
}
...
...
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