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
Boxiang Sun
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
CycleAnalytics
class
Events
include
ActionView
::
Helpers
::
DateHelper
def
initialize
(
project
:,
from
:)
@project
=
project
@from
=
from
...
...
@@ -8,7 +10,9 @@ module Gitlab
end
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
...
...
lib/gitlab/cycle_analytics/events_fetcher.rb
View file @
c545968e
...
...
@@ -13,10 +13,10 @@ module Gitlab
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
])).
project
(
diff_fn
.
as
(
'issue_diff'
),
*
issue_projections
).
project
(
extract_epoch
(
diff_fn
)
.
as
(
'issue_diff'
),
*
issue_projections
).
order
(
issue_table
[
:created_at
].
desc
)
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
)
.
first
ActiveRecord
::
Base
.
connection
.
execute
(
query
.
to_sql
)
end
def
metric_attributes
...
...
@@ -31,6 +31,10 @@ module Gitlab
def
user_table
User
.
arel_table
end
def
extract_epoch
(
arel_attribute
)
Arel
.
sql
(
%Q{EXTRACT(EPOCH FROM (
#{
arel_attribute
.
to_sql
}
))}
)
end
end
end
end
spec/lib/gitlab/cycle_analytics/events_spec.rb
View file @
c545968e
...
...
@@ -12,10 +12,10 @@ describe Gitlab::CycleAnalytics::Events do
end
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
expect
(
subject
.
issue_events
[
'issue_diff'
]).
to
eq
(
"-00:00:00.339259"
)
expect
(
subject
.
issue_events
[
'issue_diff'
]).
to
eq
(
'2 days ago'
)
end
it
'has a title'
do
...
...
@@ -23,11 +23,11 @@ describe Gitlab::CycleAnalytics::Events do
end
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
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
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