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
db62eb95
Commit
db62eb95
authored
Nov 22, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug to do with calculating durations
parent
b1b5060d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
app/serializers/analytics_build_entity.rb
app/serializers/analytics_build_entity.rb
+1
-1
app/serializers/entity_date_helper.rb
app/serializers/entity_date_helper.rb
+1
-1
spec/serializers/analytics_build_entity_spec.rb
spec/serializers/analytics_build_entity_spec.rb
+9
-1
No files found.
app/serializers/analytics_build_entity.rb
View file @
db62eb95
...
...
@@ -13,7 +13,7 @@ class AnalyticsBuildEntity < Grape::Entity
end
expose
:duration
,
as: :total_time
do
|
build
|
distance_of_time_as_hash
(
build
[
:duration
]
.
to_f
)
distance_of_time_as_hash
(
build
.
duration
.
to_f
)
end
expose
:branch
do
...
...
app/serializers/entity_date_helper.rb
View file @
db62eb95
...
...
@@ -2,7 +2,7 @@ module EntityDateHelper
include
ActionView
::
Helpers
::
DateHelper
def
interval_in_words
(
diff
)
"
#{
distance_of_time_in_words
(
diff
.
to_
f
)
}
ago"
"
#{
distance_of_time_in_words
(
Time
.
now
,
dif
f
)
}
ago"
end
# Converts seconds into a hash such as:
...
...
spec/serializers/analytics_build_entity_spec.rb
View file @
db62eb95
...
...
@@ -7,7 +7,7 @@ describe AnalyticsBuildEntity do
context
'build with an author'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:build
)
{
create
(
:ci_build
,
author:
user
)
}
let
(
:build
)
{
create
(
:ci_build
,
author:
user
,
started_at:
2
.
hours
.
ago
,
finished_at:
1
.
hour
.
ago
)
}
subject
{
entity
.
as_json
}
...
...
@@ -23,5 +23,13 @@ describe AnalyticsBuildEntity do
expect
(
subject
).
not_to
include
(
/token/
)
expect
(
subject
).
not_to
include
(
/variables/
)
end
it
'contains the right started at'
do
expect
(
subject
[
:date
]).
to
eq
(
'about 2 hours ago'
)
end
it
'contains the duration'
do
expect
(
subject
[
:total_time
]).
to
eq
({
:hours
=>
1
})
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