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
Jérome Perrin
gitlab-ce
Commits
1f701cb5
Commit
1f701cb5
authored
Oct 21, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added staging events and spec
parent
f8acc7ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
2 deletions
+47
-2
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+7
-0
lib/gitlab/cycle_analytics/events_fetcher.rb
lib/gitlab/cycle_analytics/events_fetcher.rb
+14
-2
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+26
-0
No files found.
lib/gitlab/cycle_analytics/events.rb
View file @
1f701cb5
...
...
@@ -39,6 +39,13 @@ module Gitlab
@fetcher
.
fetch_review_events
.
each
{
|
event
|
parse_event
(
event
)
}
end
def
staging_events
@fetcher
.
fetch_staging_events
.
each
do
|
event
|
event
[
'total_time'
]
=
distance_of_time_in_words
(
event
[
'total_time'
].
to_f
)
event
[
'pipeline'
]
=
::
Ci
::
Pipeline
.
find_by_id
(
event
[
'ci_commit_id'
])
# we may not have a pipeline
end
end
private
def
parse_event
(
event
)
...
...
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
1f701cb5
...
...
@@ -46,7 +46,7 @@ module Gitlab
end
def
fetch_test_events
base_query
=
base_query_for
(
:
code
)
base_query
=
base_query_for
(
:
test
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
mr_metrics_table
[
:latest_build_started_at
],
mr_metrics_table
[
:latest_build_finished_at
])
...
...
@@ -58,7 +58,7 @@ module Gitlab
end
def
fetch_review_events
base_query
=
base_query_for
(
:
code
)
base_query
=
base_query_for
(
:
review
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
mr_table
[
:created_at
],
mr_metrics_table
[
:merged_at
])
...
...
@@ -70,6 +70,18 @@ module Gitlab
execute
(
query
)
end
def
fetch_staging_events
base_query
=
base_query_for
(
:staging
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
mr_metrics_table
[
:merged_at
],
mr_metrics_table
[
:first_deployed_to_production_at
])
query
=
base_query
.
project
(
extract_epoch
(
diff_fn
).
as
(
'total_time'
),
mr_metrics_table
[
:ci_commit_id
]).
order
(
mr_table
[
:created_at
].
desc
)
execute
(
query
)
end
private
def
issue_attributes
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
1f701cb5
...
...
@@ -123,6 +123,32 @@ describe Gitlab::CycleAnalytics::Events do
end
end
describe
'#staging_events'
do
let!
(
:context
)
{
create
(
:issue
,
project:
project
,
created_at:
2
.
days
.
ago
)
}
let
(
:merge_request
)
{
MergeRequest
.
first
}
let!
(
:pipeline
)
do
create
(
:ci_pipeline
,
ref:
merge_request
.
source_branch
,
sha:
merge_request
.
diff_head_sha
,
project:
context
.
project
)
end
before
do
pipeline
.
run!
pipeline
.
succeed!
merge_merge_requests_closing_issue
(
context
)
deploy_master
end
it
'has the build info as a pipeline'
do
expect
(
subject
.
staging_events
.
first
[
'pipeline'
]).
to
eq
(
pipeline
)
end
it
'has the total time'
do
expect
(
subject
.
staging_events
.
first
[
'total_time'
]).
to
eq
(
'less than a minute'
)
end
end
def
setup
(
context
)
milestone
=
create
(
:milestone
,
project:
project
)
context
.
update
(
milestone:
milestone
)
...
...
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