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
830f739b
Commit
830f739b
authored
Nov 25, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use an empty total time when the build has not started yet so the UI knows
parent
aa895a64
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
3 deletions
+29
-3
app/serializers/analytics_build_entity.rb
app/serializers/analytics_build_entity.rb
+5
-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
+23
-1
No files found.
app/serializers/analytics_build_entity.rb
View file @
830f739b
...
@@ -13,7 +13,7 @@ class AnalyticsBuildEntity < Grape::Entity
...
@@ -13,7 +13,7 @@ class AnalyticsBuildEntity < Grape::Entity
end
end
expose
:duration
,
as: :total_time
do
|
build
|
expose
:duration
,
as: :total_time
do
|
build
|
distance_of_time_as_hash
(
build
.
duration
.
to_f
)
build_started?
(
build
)
?
distance_of_time_as_hash
(
build
.
duration
.
to_f
)
:
{}
end
end
expose
:branch
do
expose
:branch
do
...
@@ -37,4 +37,8 @@ class AnalyticsBuildEntity < Grape::Entity
...
@@ -37,4 +37,8 @@ class AnalyticsBuildEntity < Grape::Entity
def
url_to
(
route
,
build
,
id
=
nil
)
def
url_to
(
route
,
build
,
id
=
nil
)
public_send
(
"
#{
route
}
_url"
,
build
.
project
.
namespace
,
build
.
project
,
id
||
build
)
public_send
(
"
#{
route
}
_url"
,
build
.
project
.
namespace
,
build
.
project
,
id
||
build
)
end
end
def
build_started?
(
build
)
build
.
duration
&&
build
[
:started_at
]
end
end
end
app/serializers/entity_date_helper.rb
View file @
830f739b
...
@@ -2,7 +2,7 @@ module EntityDateHelper
...
@@ -2,7 +2,7 @@ module EntityDateHelper
include
ActionView
::
Helpers
::
DateHelper
include
ActionView
::
Helpers
::
DateHelper
def
interval_in_words
(
diff
)
def
interval_in_words
(
diff
)
return
'
n
ot started'
unless
diff
return
'
N
ot started'
unless
diff
"
#{
distance_of_time_in_words
(
Time
.
now
,
diff
)
}
ago"
"
#{
distance_of_time_in_words
(
Time
.
now
,
diff
)
}
ago"
end
end
...
...
spec/serializers/analytics_build_entity_spec.rb
View file @
830f739b
...
@@ -42,7 +42,13 @@ describe AnalyticsBuildEntity do
...
@@ -42,7 +42,13 @@ describe AnalyticsBuildEntity do
expect
{
subject
[
:date
]
}.
not_to
raise_error
expect
{
subject
[
:date
]
}.
not_to
raise_error
end
end
it
''
it
'shows the right message'
do
expect
(
subject
[
:date
]).
to
eq
(
'Not started'
)
end
it
'shows the right total time'
do
expect
(
subject
[
:total_time
]).
to
eq
({})
end
end
end
context
'no started at date'
do
context
'no started at date'
do
...
@@ -51,6 +57,14 @@ describe AnalyticsBuildEntity do
...
@@ -51,6 +57,14 @@ describe AnalyticsBuildEntity do
it
'does not blow up'
do
it
'does not blow up'
do
expect
{
subject
[
:date
]
}.
not_to
raise_error
expect
{
subject
[
:date
]
}.
not_to
raise_error
end
end
it
'shows the right message'
do
expect
(
subject
[
:date
]).
to
eq
(
'Not started'
)
end
it
'shows the right total time'
do
expect
(
subject
[
:total_time
]).
to
eq
({})
end
end
end
context
'no finished at date'
do
context
'no finished at date'
do
...
@@ -59,6 +73,14 @@ describe AnalyticsBuildEntity do
...
@@ -59,6 +73,14 @@ describe AnalyticsBuildEntity do
it
'does not blow up'
do
it
'does not blow up'
do
expect
{
subject
[
:date
]
}.
not_to
raise_error
expect
{
subject
[
:date
]
}.
not_to
raise_error
end
end
it
'shows the right message'
do
expect
(
subject
[
:date
]).
to
eq
(
'about 2 hours ago'
)
end
it
'shows the right total time'
do
expect
(
subject
[
:total_time
]).
to
eq
({
hours:
2
})
end
end
end
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