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
cbc9f0cd
Commit
cbc9f0cd
authored
Nov 16, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue with commits and also updated routes
parent
633ddc9e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
8 deletions
+23
-8
app/controllers/projects/cycle_analytics/events_controller.rb
...controllers/projects/cycle_analytics/events_controller.rb
+5
-1
config/routes/project.rb
config/routes/project.rb
+1
-1
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+13
-5
lib/gitlab/cycle_analytics/query_config.rb
lib/gitlab/cycle_analytics/query_config.rb
+2
-1
spec/requests/projects/cycle_analytics_events_spec.rb
spec/requests/projects/cycle_analytics_events_spec.rb
+2
-0
No files found.
app/controllers/projects/cycle_analytics/events_controller.rb
View file @
cbc9f0cd
class
Projects::CycleAnalytics::EventsController
<
Projects
::
ApplicationController
module
Projects
module
CycleAnalytics
class
EventsController
<
Projects
::
ApplicationController
include
CycleAnalyticsParams
before_action
:authorize_read_cycle_analytics!
...
...
@@ -60,4 +62,6 @@ class Projects::CycleAnalytics::EventsController < Projects::ApplicationControll
def
authorize_builds!
return
access_denied!
unless
current_user
.
can?
(
:read_build
,
project
)
end
end
end
end
config/routes/project.rb
View file @
cbc9f0cd
...
...
@@ -154,7 +154,7 @@ resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only:
resource
:cycle_analytics
,
only:
[
:show
]
namespace
:cycle_analytics
do
scope
:events
,
controller:
'
/projects/cycle_analytics/
events'
do
scope
:events
,
controller:
'events'
do
get
:issue
get
:plan
get
:code
...
...
lib/gitlab/cycle_analytics/events.rb
View file @
cbc9f0cd
...
...
@@ -12,9 +12,11 @@ module Gitlab
def
plan_events
@fetcher
.
fetch
(
stage: :plan
).
map
do
|
event
|
commit
=
first_time_reference_commit
(
event
.
delete
(
'commits'
),
event
)
st_
commit
=
first_time_reference_commit
(
event
.
delete
(
'commits'
),
event
)
AnalyticsCommitSerializer
.
new
(
project:
@project
,
total_time:
event
[
'total_time'
]).
represent
(
commit
).
as_json
next
unless
st_commit
serialize_commit
(
event
,
st_commit
)
end
end
...
...
@@ -53,11 +55,17 @@ module Gitlab
end
def
first_time_reference_commit
(
commits
,
event
)
st_commit
=
YAML
.
load
(
commits
).
detect
do
|
commit
|
commit
[
'created_at'
]
==
event
[
'first_mentioned_in_commit_at'
]
YAML
.
load
(
commits
).
find
do
|
commit
|
next
unless
commit
[
:committed_date
]
&&
event
[
'first_mentioned_in_commit_at'
]
commit
[
:committed_date
].
to_i
==
DateTime
.
parse
(
event
[
'first_mentioned_in_commit_at'
]).
to_i
end
end
def
serialize_commit
(
event
,
st_commit
)
commit
=
Commit
.
new
(
Gitlab
::
Git
::
Commit
.
new
(
st_commit
),
@project
)
Commit
.
new
(
Gitlab
::
Git
::
Commit
.
new
(
st_commit
),
@project
)
AnalyticsCommitSerializer
.
new
(
project:
@project
,
total_time:
event
[
'total_time'
]).
represent
(
commit
).
as_json
end
def
interval_in_words
(
diff
)
...
...
lib/gitlab/cycle_analytics/query_config.rb
View file @
cbc9f0cd
...
...
@@ -33,7 +33,8 @@ module Gitlab
start_time_attrs:
issue_metrics_table
[
:first_associated_with_milestone_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_added_to_board_at
],
issue_metrics_table
[
:first_mentioned_in_commit_at
]],
projections:
[
mr_diff_table
[
:st_commits
].
as
(
'commits'
)]
projections:
[
mr_diff_table
[
:st_commits
].
as
(
'commits'
),
issue_metrics_table
[
:first_mentioned_in_commit_at
]]
}
end
...
...
spec/requests/projects/cycle_analytics_events_spec.rb
View file @
cbc9f0cd
...
...
@@ -142,5 +142,7 @@ describe 'cycle analytics events' do
create
(
:ci_build
,
pipeline:
pipeline
,
status: :success
,
author:
user
)
merge_merge_requests_closing_issue
(
issue
)
Issue
::
Metrics
.
update_all
(
first_mentioned_in_commit_at:
mr
.
commits
.
last
.
committed_date
)
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