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
d99cec7f
Commit
d99cec7f
authored
Oct 21, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
review events - spec and logic
parent
ebd5ced7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
8 deletions
+49
-8
lib/gitlab/cycle_analytics/events.rb
lib/gitlab/cycle_analytics/events.rb
+11
-8
lib/gitlab/cycle_analytics/events_fetcher.rb
lib/gitlab/cycle_analytics/events_fetcher.rb
+13
-0
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+25
-0
No files found.
lib/gitlab/cycle_analytics/events.rb
View file @
d99cec7f
...
...
@@ -13,10 +13,7 @@ module Gitlab
def
issue_events
# TODO figure out what the frontend needs for displaying the avatar
@fetcher
.
fetch_issue_events
.
each
do
|
event
|
event
[
'total_time'
]
=
distance_of_time_in_words
(
event
[
'total_time'
].
to_f
)
event
[
'created_at'
]
=
interval_in_words
(
event
[
'created_at'
])
end
@fetcher
.
fetch_issue_events
{
|
event
|
parse_event
(
event
)
}
end
def
plan_events
...
...
@@ -28,10 +25,7 @@ module Gitlab
end
def
code_events
@fetcher
.
fetch_code_events
.
each
do
|
event
|
event
[
'total_time'
]
=
distance_of_time_in_words
(
event
[
'total_time'
].
to_f
)
event
[
'created_at'
]
=
interval_in_words
(
event
[
'created_at'
])
end
@fetcher
.
fetch_code_events
{
|
event
|
parse_event
(
event
)
}
end
def
test_events
...
...
@@ -41,6 +35,15 @@ module Gitlab
end
end
def
review_events
@fetcher
.
fetch_review_events
.
each
{
|
event
|
parse_event
(
event
)
}
end
def
parse_event
(
event
)
event
[
'total_time'
]
=
distance_of_time_in_words
(
event
[
'total_time'
].
to_f
)
event
[
'created_at'
]
=
interval_in_words
(
event
[
'created_at'
])
end
private
def
first_time_reference_commit
(
commits
,
event
)
...
...
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
d99cec7f
...
...
@@ -57,6 +57,19 @@ module Gitlab
execute
(
query
)
end
def
fetch_review_events
base_query
=
base_query_for
(
:code
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
mr_table
[
:created_at
],
mr_metrics_table
[
:merged_at
])
query
=
base_query
.
join
(
user_table
).
on
(
mr_table
[
:author_id
].
eq
(
user_table
[
:id
])).
project
(
extract_epoch
(
diff_fn
).
as
(
'total_time'
),
*
code_projections
).
order
(
mr_table
[
:created_at
].
desc
)
execute
(
query
)
end
private
def
issue_attributes
...
...
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
d99cec7f
...
...
@@ -97,6 +97,31 @@ describe Gitlab::CycleAnalytics::Events do
end
end
describe
'#review_events'
do
let!
(
:context
)
{
create
(
:issue
,
project:
project
,
created_at:
2
.
days
.
ago
)
}
it
'has the total time'
do
expect
(
subject
.
review_events
.
first
[
'total_time'
]).
to
eq
(
'less than a minute'
)
end
it
'has a title'
do
expect
(
subject
.
review_events
.
first
[
'title'
]).
to
eq
(
'Awesome merge_request'
)
end
it
'has an iid'
do
expect
(
subject
.
review_events
.
first
[
'iid'
]).
to
eq
(
context
.
iid
.
to_s
)
end
it
'has a created_at timestamp'
do
expect
(
subject
.
review_events
.
first
[
'created_at'
]).
to
end_with
(
'ago'
)
end
it
"has the author's name"
do
expect
(
subject
.
review_events
.
first
[
'name'
]).
to
eq
(
MergeRequest
.
first
.
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