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
7c109c57
Commit
7c109c57
authored
Feb 09, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor CycleAnalytics base stage class and model
parent
a7b3f11e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
app/models/cycle_analytics.rb
app/models/cycle_analytics.rb
+1
-1
app/serializers/analytics_stage_entity.rb
app/serializers/analytics_stage_entity.rb
+8
-2
lib/gitlab/cycle_analytics/base_query.rb
lib/gitlab/cycle_analytics/base_query.rb
+1
-5
No files found.
app/models/cycle_analytics.rb
View file @
7c109c57
...
@@ -31,7 +31,7 @@ class CycleAnalytics
...
@@ -31,7 +31,7 @@ class CycleAnalytics
end
end
def
[]
(
stage_name
)
def
[]
(
stage_name
)
Gitlab
::
CycleAnalytics
::
Stage
[
stage_name
].
new
(
project
:
@project
,
options:
@options
)
Gitlab
::
CycleAnalytics
::
Stage
[
stage_name
].
new
(
project
s:
[
@project
]
,
options:
@options
)
end
end
private
private
...
...
app/serializers/analytics_stage_entity.rb
View file @
7c109c57
...
@@ -6,7 +6,13 @@ class AnalyticsStageEntity < Grape::Entity
...
@@ -6,7 +6,13 @@ class AnalyticsStageEntity < Grape::Entity
expose
:legend
expose
:legend
expose
:description
expose
:description
expose
:median
,
as: :value
do
|
stage
|
expose
:medians
,
as: :values
do
|
stage
|
stage
.
median
&&
!
stage
.
median
.
zero?
?
distance_of_time_in_words
(
stage
.
median
)
:
nil
medians
=
stage
.
medians
unless
medians
.
blank?
medians
.
each
do
|
id
,
median
|
medians
[
id
]
=
distance_of_time_in_words
(
median
)
end
end
end
end
end
end
lib/gitlab/cycle_analytics/base_query.rb
View file @
7c109c57
...
@@ -14,7 +14,7 @@ module Gitlab
...
@@ -14,7 +14,7 @@ module Gitlab
def
stage_query
def
stage_query
query
=
mr_closing_issues_table
.
join
(
issue_table
).
on
(
issue_table
[
:id
].
eq
(
mr_closing_issues_table
[
:issue_id
]))
query
=
mr_closing_issues_table
.
join
(
issue_table
).
on
(
issue_table
[
:id
].
eq
(
mr_closing_issues_table
[
:issue_id
]))
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
where
(
issue_table
[
:project_id
].
in
(
project_ids
))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:project_id
].
in
(
Arel
.
sql
(
@projects
.
select
(
:id
).
to_sql
)
))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
# Load merge_requests
# Load merge_requests
...
@@ -26,10 +26,6 @@ module Gitlab
...
@@ -26,10 +26,6 @@ module Gitlab
query
query
end
end
def
project_ids
@projects
.
map
(
&
:id
)
end
end
end
end
end
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