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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
198df06f
Commit
198df06f
authored
Jul 10, 2019
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add attribute reader
parent
2d283dd4
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
24 additions
and
22 deletions
+24
-22
lib/gitlab/cycle_analytics/base_event_fetcher.rb
lib/gitlab/cycle_analytics/base_event_fetcher.rb
+6
-6
lib/gitlab/cycle_analytics/base_query.rb
lib/gitlab/cycle_analytics/base_query.rb
+1
-1
lib/gitlab/cycle_analytics/base_stage.rb
lib/gitlab/cycle_analytics/base_stage.rb
+8
-6
lib/gitlab/cycle_analytics/code_event_fetcher.rb
lib/gitlab/cycle_analytics/code_event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/issue_event_fetcher.rb
lib/gitlab/cycle_analytics/issue_event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/issue_helper.rb
lib/gitlab/cycle_analytics/issue_helper.rb
+1
-1
lib/gitlab/cycle_analytics/plan_event_fetcher.rb
lib/gitlab/cycle_analytics/plan_event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/plan_helper.rb
lib/gitlab/cycle_analytics/plan_helper.rb
+1
-1
lib/gitlab/cycle_analytics/production_event_fetcher.rb
lib/gitlab/cycle_analytics/production_event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/production_helper.rb
lib/gitlab/cycle_analytics/production_helper.rb
+1
-1
lib/gitlab/cycle_analytics/review_event_fetcher.rb
lib/gitlab/cycle_analytics/review_event_fetcher.rb
+1
-1
lib/gitlab/cycle_analytics/test_helper.rb
lib/gitlab/cycle_analytics/test_helper.rb
+1
-1
No files found.
lib/gitlab/cycle_analytics/base_event_fetcher.rb
View file @
198df06f
...
...
@@ -5,7 +5,7 @@ module Gitlab
class
BaseEventFetcher
include
BaseQuery
attr_reader
:projections
,
:query
,
:stage
,
:order
attr_reader
:projections
,
:query
,
:stage
,
:order
,
:project
,
:options
MAX_EVENTS
=
50
...
...
@@ -40,13 +40,13 @@ module Gitlab
end
def
events_query
diff_fn
=
subtract_datetimes_diff
(
base_query
,
@options
[
:start_time_attrs
],
@
options
[
:end_time_attrs
])
diff_fn
=
subtract_datetimes_diff
(
base_query
,
options
[
:start_time_attrs
],
options
[
:end_time_attrs
])
base_query
.
project
(
extract_diff_epoch
(
diff_fn
).
as
(
'total_time'
),
*
projections
).
order
(
order
.
desc
).
take
(
MAX_EVENTS
)
end
def
default_order
[
@
options
[
:start_time_attrs
]].
flatten
.
first
[
options
[
:start_time_attrs
]].
flatten
.
first
end
def
serialize
(
_event
)
...
...
@@ -59,7 +59,7 @@ module Gitlab
def
allowed_ids
@allowed_ids
||=
allowed_ids_finder_class
.
new
(
@
options
[
:current_user
],
allowed_ids_source
)
.
new
(
options
[
:current_user
],
allowed_ids_source
)
.
execute
.
where
(
id:
event_result_ids
).
pluck
(
:id
)
end
...
...
@@ -68,11 +68,11 @@ module Gitlab
end
def
allowed_ids_source
{
project_id:
@
project
.
id
}
{
project_id:
project
.
id
}
end
def
projects
[
@
project
]
[
project
]
end
end
end
...
...
lib/gitlab/cycle_analytics/base_query.rb
View file @
198df06f
...
...
@@ -18,7 +18,7 @@ module Gitlab
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
project
(
issue_table
[
:project_id
].
as
(
"project_id"
))
.
where
(
issue_table
[
:project_id
].
in
(
project_ids
))
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:created_at
].
gteq
(
options
[
:from
]))
# Load merge_requests
query
=
query
.
join
(
mr_table
,
Arel
::
Nodes
::
OuterJoin
)
...
...
lib/gitlab/cycle_analytics/base_stage.rb
View file @
198df06f
...
...
@@ -5,6 +5,8 @@ module Gitlab
class
BaseStage
include
BaseQuery
attr_reader
:project
,
:options
def
initialize
(
project:
nil
,
options
:)
@project
=
project
@options
=
options
...
...
@@ -23,11 +25,11 @@ module Gitlab
end
def
median
return
if
@
project
.
nil?
return
if
project
.
nil?
BatchLoader
.
for
(
@
project
.
id
).
batch
(
key:
name
)
do
|
project_ids
,
loader
|
BatchLoader
.
for
(
project
.
id
).
batch
(
key:
name
)
do
|
project_ids
,
loader
|
if
project_ids
.
one?
loader
.
call
(
@
project
.
id
,
median_query
(
project_ids
))
loader
.
call
(
project
.
id
,
median_query
(
project_ids
))
else
begin
median_datetimes
(
cte_table
,
interval_query
(
project_ids
),
name
,
:project_id
)
&
.
each
do
|
project_id
,
median
|
...
...
@@ -65,17 +67,17 @@ module Gitlab
private
def
event_fetcher
@event_fetcher
||=
Gitlab
::
CycleAnalytics
::
EventFetcher
[
name
].
new
(
project:
@
project
,
@event_fetcher
||=
Gitlab
::
CycleAnalytics
::
EventFetcher
[
name
].
new
(
project:
project
,
stage:
name
,
options:
event_options
)
end
def
event_options
@
options
.
merge
(
start_time_attrs:
start_time_attrs
,
end_time_attrs:
end_time_attrs
)
options
.
merge
(
start_time_attrs:
start_time_attrs
,
end_time_attrs:
end_time_attrs
)
end
def
projects
[
@
project
]
[
project
]
end
end
end
...
...
lib/gitlab/cycle_analytics/code_event_fetcher.rb
View file @
198df06f
...
...
@@ -20,7 +20,7 @@ module Gitlab
private
def
serialize
(
event
)
AnalyticsMergeRequestSerializer
.
new
(
project:
@
project
).
represent
(
event
)
AnalyticsMergeRequestSerializer
.
new
(
project:
project
).
represent
(
event
)
end
def
allowed_ids_finder_class
...
...
lib/gitlab/cycle_analytics/issue_event_fetcher.rb
View file @
198df06f
...
...
@@ -18,7 +18,7 @@ module Gitlab
private
def
serialize
(
event
)
AnalyticsIssueSerializer
.
new
(
project:
@
project
).
represent
(
event
)
AnalyticsIssueSerializer
.
new
(
project:
project
).
represent
(
event
)
end
def
allowed_ids_finder_class
...
...
lib/gitlab/cycle_analytics/issue_helper.rb
View file @
198df06f
...
...
@@ -7,7 +7,7 @@ module Gitlab
query
=
issue_table
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
project
(
issue_table
[
:project_id
].
as
(
"project_id"
))
.
where
(
issue_table
[
:project_id
].
in
(
project_ids
))
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:created_at
].
gteq
(
options
[
:from
]))
.
where
(
issue_metrics_table
[
:first_added_to_board_at
].
not_eq
(
nil
).
or
(
issue_metrics_table
[
:first_associated_with_milestone_at
].
not_eq
(
nil
)))
query
...
...
lib/gitlab/cycle_analytics/plan_event_fetcher.rb
View file @
198df06f
...
...
@@ -18,7 +18,7 @@ module Gitlab
private
def
serialize
(
event
)
AnalyticsIssueSerializer
.
new
(
project:
@
project
).
represent
(
event
)
AnalyticsIssueSerializer
.
new
(
project:
project
).
represent
(
event
)
end
def
allowed_ids_finder_class
...
...
lib/gitlab/cycle_analytics/plan_helper.rb
View file @
198df06f
...
...
@@ -7,7 +7,7 @@ module Gitlab
query
=
issue_table
.
join
(
issue_metrics_table
).
on
(
issue_table
[
:id
].
eq
(
issue_metrics_table
[
:issue_id
]))
.
project
(
issue_table
[
:project_id
].
as
(
"project_id"
))
.
where
(
issue_table
[
:project_id
].
in
(
project_ids
))
.
where
(
issue_table
[
:created_at
].
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
where
(
issue_table
[
:created_at
].
gteq
(
options
[
:from
]))
.
where
(
issue_metrics_table
[
:first_added_to_board_at
].
not_eq
(
nil
).
or
(
issue_metrics_table
[
:first_associated_with_milestone_at
].
not_eq
(
nil
)))
.
where
(
issue_metrics_table
[
:first_mentioned_in_commit_at
].
not_eq
(
nil
))
...
...
lib/gitlab/cycle_analytics/production_event_fetcher.rb
View file @
198df06f
...
...
@@ -18,7 +18,7 @@ module Gitlab
private
def
serialize
(
event
)
AnalyticsIssueSerializer
.
new
(
project:
@
project
).
represent
(
event
)
AnalyticsIssueSerializer
.
new
(
project:
project
).
represent
(
event
)
end
def
allowed_ids_finder_class
...
...
lib/gitlab/cycle_analytics/production_helper.rb
View file @
198df06f
...
...
@@ -6,7 +6,7 @@ module Gitlab
def
stage_query
(
project_ids
)
super
(
project_ids
)
.
where
(
mr_metrics_table
[
:first_deployed_to_production_at
]
.
gteq
(
@options
[
:from
]))
# rubocop:disable Gitlab/ModuleWithInstanceVariables
.
gteq
(
options
[
:from
]))
end
end
end
...
...
lib/gitlab/cycle_analytics/review_event_fetcher.rb
View file @
198df06f
...
...
@@ -19,7 +19,7 @@ module Gitlab
private
def
serialize
(
event
)
AnalyticsMergeRequestSerializer
.
new
(
project:
@
project
).
represent
(
event
)
AnalyticsMergeRequestSerializer
.
new
(
project:
project
).
represent
(
event
)
end
def
allowed_ids_finder_class
...
...
lib/gitlab/cycle_analytics/test_helper.rb
View file @
198df06f
...
...
@@ -14,7 +14,7 @@ module Gitlab
private
def
branch
@branch
||=
@options
[
:branch
]
# rubocop:disable Gitlab/ModuleWithInstanceVariables
@branch
||=
options
[
:branch
]
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