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
Léo-Paul Géneau
gitlab-ce
Commits
3cdc9af7
Commit
3cdc9af7
authored
Oct 21, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added production events and related spec
parent
275292de
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
11 deletions
+44
-11
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+5
-1
lib/gitlab/cycle_analytics/events_fetcher.rb
lib/gitlab/cycle_analytics/events_fetcher.rb
+10
-10
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+29
-0
No files found.
lib/gitlab/cycle_analytics/events.rb
View file @
3cdc9af7
...
...
@@ -10,9 +10,9 @@ module Gitlab
end
# TODO: backend pagination - specially for commits, etc...
# TODO figure out what the frontend needs for displaying the avatar
def
issue_events
# TODO figure out what the frontend needs for displaying the avatar
@fetcher
.
fetch
(
stage: :issue
).
each
{
|
event
|
parse_event
(
event
)
}
end
...
...
@@ -46,6 +46,10 @@ module Gitlab
end
end
def
production_events
@fetcher
.
fetch
(
stage: :production
).
each
{
|
event
|
parse_event
(
event
)
}
end
private
def
parse_event
(
event
)
...
...
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
3cdc9af7
...
...
@@ -8,9 +8,7 @@ module Gitlab
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
]],
project:
@project
,
from:
@from
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
]]
},
plan:
{
start_time_attrs:
issue_metrics_table
[
:first_associated_with_milestone_at
],
...
...
@@ -39,12 +37,15 @@ module Gitlab
start_time_attrs:
mr_metrics_table
[
:merged_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
mr_metrics_table
[
:ci_commit_id
]
}
},
production:
{
start_time_attrs:
issue_table
[
:created_at
],
end_time_attrs:
mr_metrics_table
[
:first_deployed_to_production_at
],
projections:
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
user_table
[
:name
]]
},
}.
freeze
def
initialize
(
project
:,
from
:)
@project
=
project
@from
=
from
@query
=
EventsQuery
.
new
(
project:
project
,
from:
from
)
end
...
...
@@ -60,14 +61,13 @@ module Gitlab
base_query
.
join
(
user_table
).
on
(
issue_table
[
:author_id
].
eq
(
user_table
[
:id
]))
end
alias_method
:code_custom_query
,
:issue_custom_query
alias_method
:production_custom_query
,
:issue_custom_query
def
plan_custom_query
(
base_query
)
base_query
.
join
(
mr_diff_table
).
on
(
mr_diff_table
[
:merge_request_id
].
eq
(
mr_table
[
:id
]))
end
def
code_custom_query
(
base_query
)
base_query
.
join
(
user_table
).
on
(
issue_table
[
:author_id
].
eq
(
user_table
[
:id
]))
end
def
review_custom_query
(
base_query
)
base_query
.
join
(
user_table
).
on
(
mr_table
[
:author_id
].
eq
(
user_table
[
:id
]))
end
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
3cdc9af7
...
...
@@ -149,6 +149,35 @@ describe Gitlab::CycleAnalytics::Events do
end
end
describe
'#production_events'
do
let!
(
:context
)
{
create
(
:issue
,
project:
project
,
created_at:
2
.
days
.
ago
)
}
before
do
merge_merge_requests_closing_issue
(
context
)
deploy_master
end
it
'has the total time'
do
expect
(
subject
.
production_events
.
first
[
'total_time'
]).
to
eq
(
'2 days'
)
end
it
'has a title'
do
expect
(
subject
.
production_events
.
first
[
'title'
]).
to
eq
(
context
.
title
)
end
it
'has an iid'
do
expect
(
subject
.
production_events
.
first
[
'iid'
]).
to
eq
(
context
.
iid
.
to_s
)
end
it
'has a created_at timestamp'
do
expect
(
subject
.
production_events
.
first
[
'created_at'
]).
to
end_with
(
'ago'
)
end
it
"has the author's name"
do
expect
(
subject
.
production_events
.
first
[
'name'
]).
to
eq
(
context
.
author
.
name
)
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