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
c545968e
Commit
c545968e
authored
Oct 17, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix timestamp diff and spec
parent
847d2796
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
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
+6
-2
spec/lib/gitlab/cycle_analytics/events_spec.rb
spec/lib/gitlab/cycle_analytics/events_spec.rb
+4
-4
No files found.
lib/gitlab/cycle_analytics/events.rb
View file @
c545968e
module
Gitlab
module
Gitlab
module
CycleAnalytics
module
CycleAnalytics
class
Events
class
Events
include
ActionView
::
Helpers
::
DateHelper
def
initialize
(
project
:,
from
:)
def
initialize
(
project
:,
from
:)
@project
=
project
@project
=
project
@from
=
from
@from
=
from
...
@@ -8,7 +10,9 @@ module Gitlab
...
@@ -8,7 +10,9 @@ module Gitlab
end
end
def
issue_events
def
issue_events
@fetcher
.
fetch_issues
@fetcher
.
fetch_issues
.
each
do
|
event
|
event
[
'issue_diff'
]
=
distance_of_time_in_words
(
event
[
'issue_diff'
].
to_f
)
end
end
end
end
end
end
end
...
...
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
c545968e
...
@@ -13,10 +13,10 @@ module Gitlab
...
@@ -13,10 +13,10 @@ module Gitlab
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
.
join
(
user_table
).
on
(
issue_table
[
:author_id
].
eq
(
user_table
[
:id
])).
query
=
base_query
.
join
(
user_table
).
on
(
issue_table
[
:author_id
].
eq
(
user_table
[
:id
])).
project
(
diff_fn
.
as
(
'issue_diff'
),
*
issue_projections
).
project
(
extract_epoch
(
diff_fn
)
.
as
(
'issue_diff'
),
*
issue_projections
).
order
(
issue_table
[
:created_at
].
desc
)
order
(
issue_table
[
:created_at
].
desc
)
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
)
.
first
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
)
end
end
def
metric_attributes
def
metric_attributes
...
@@ -31,6 +31,10 @@ module Gitlab
...
@@ -31,6 +31,10 @@ module Gitlab
def
user_table
def
user_table
User
.
arel_table
User
.
arel_table
end
end
def
extract_epoch
(
arel_attribute
)
Arel
.
sql
(
%Q{EXTRACT(EPOCH FROM (
#{
arel_attribute
.
to_sql
}
))}
)
end
end
end
end
end
end
end
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
c545968e
...
@@ -12,10 +12,10 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -12,10 +12,10 @@ describe Gitlab::CycleAnalytics::Events do
end
end
describe
'#issue'
do
describe
'#issue'
do
let!
(
:context
)
{
create
(
:issue
,
project:
project
)
}
let!
(
:context
)
{
create
(
:issue
,
project:
project
,
created_at:
2
.
days
.
ago
)
}
it
'has an issue diff'
do
it
'has an issue diff'
do
expect
(
subject
.
issue_events
[
'issue_diff'
]).
to
eq
(
"-00:00:00.339259"
)
expect
(
subject
.
issue_events
[
'issue_diff'
]).
to
eq
(
'2 days ago'
)
end
end
it
'has a title'
do
it
'has a title'
do
...
@@ -23,11 +23,11 @@ describe Gitlab::CycleAnalytics::Events do
...
@@ -23,11 +23,11 @@ describe Gitlab::CycleAnalytics::Events do
end
end
it
'has an iid'
do
it
'has an iid'
do
expect
(
subject
.
issue_events
[
'iid'
]).
to
eq
(
context
.
iid
)
expect
(
subject
.
issue_events
[
'iid'
]).
to
eq
(
context
.
iid
.
to_s
)
end
end
it
'has a created_at timestamp'
do
it
'has a created_at timestamp'
do
expect
(
subject
.
issue_events
[
'created_at'
]).
to
eq
(
context
.
created_at
)
expect
(
subject
.
issue_events
[
'created_at'
]).
to
eq
(
'2 days ago'
)
end
end
it
"has the author's name"
do
it
"has the author's name"
do
...
...
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