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
847d2796
Commit
847d2796
authored
Oct 17, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed spec and SQL query
parent
470e39d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
12 deletions
+30
-12
lib/gitlab/cycle_analytics/events_fetcher.rb
lib/gitlab/cycle_analytics/events_fetcher.rb
+12
-10
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+18
-2
No files found.
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
847d2796
...
@@ -9,26 +9,28 @@ module Gitlab
...
@@ -9,26 +9,28 @@ module Gitlab
end
end
def
fetch_issues
def
fetch_issues
cte_table
=
Arel
::
Table
.
new
(
"cte_table_for_issue"
)
# Build a `SELECT` query. We find the first of the `end_time_attrs` that isn't `NULL` (call this end_time).
# Next, we find the first of the start_time_attrs that isn't `NULL` (call this start_time).
# We compute the (end_time - start_time) interval, and give it an alias based on the current
# cycle analytics stage.
base_query
=
base_query_for
(
:issue
)
base_query
=
base_query_for
(
:issue
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
issue_table
[
:created_at
],
metric_attributes
)
diff_fn
=
subtract_datetimes_diff
(
base_query
,
issue_table
[
:created_at
],
metric_attributes
)
query
=
base_query
.
project
(
diff_fn
.
as
(
'issue_diff'
))
query
=
base_query
.
join
(
user_table
).
on
(
issue_table
[
:author_id
].
eq
(
user_table
[
:id
])).
project
(
diff_fn
.
as
(
'issue_diff'
),
*
issue_projections
).
order
(
issue_table
[
:created_at
].
desc
)
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
)
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
)
.
first
end
end
def
metric_attributes
def
metric_attributes
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
[
issue_metrics_table
[
:first_associated_with_milestone_at
],
issue_metrics_table
[
:first_added_to_board_at
]]
issue_metrics_table
[
:first_added_to_board_at
]]
end
end
def
issue_projections
[
issue_table
[
:title
],
issue_table
[
:iid
],
issue_table
[
:created_at
],
User
.
arel_table
[
:name
]]
end
def
user_table
User
.
arel_table
end
end
end
end
end
end
end
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
847d2796
...
@@ -14,8 +14,24 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -14,8 +14,24 @@ describe Gitlab::CycleAnalytics::Events do
describe
'#issue'
do
describe
'#issue'
do
let!
(
:context
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:context
)
{
create
(
:issue
,
project:
project
)
}
xit
'does something'
do
it
'has an issue diff'
do
expect
(
subject
.
issue_events
).
to
eq
([
context
])
expect
(
subject
.
issue_events
[
'issue_diff'
]).
to
eq
(
"-00:00:00.339259"
)
end
it
'has a title'
do
expect
(
subject
.
issue_events
[
'title'
]).
to
eq
(
context
.
title
)
end
it
'has an iid'
do
expect
(
subject
.
issue_events
[
'iid'
]).
to
eq
(
context
.
iid
)
end
it
'has a created_at timestamp'
do
expect
(
subject
.
issue_events
[
'created_at'
]).
to
eq
(
context
.
created_at
)
end
it
"has the author's name"
do
expect
(
subject
.
issue_events
[
'name'
]).
to
eq
(
context
.
author
.
name
)
end
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