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
ea38e832
Commit
ea38e832
authored
Sep 27, 2018
by
Winnie Hellmann
Committed by
Alessio Caiazza
Oct 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow remaining time of scheduled jobs to overflow one day
parent
f976418d
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
16 deletions
+48
-16
app/helpers/time_helper.rb
app/helpers/time_helper.rb
+15
-3
app/views/projects/ci/builds/_build.html.haml
app/views/projects/ci/builds/_build.html.haml
+1
-1
lib/gitlab/ci/status/build/scheduled.rb
lib/gitlab/ci/status/build/scheduled.rb
+4
-2
spec/helpers/time_helper_spec.rb
spec/helpers/time_helper_spec.rb
+28
-10
No files found.
app/helpers/time_helper.rb
View file @
ea38e832
...
...
@@ -21,9 +21,21 @@ module TimeHelper
"
#{
from
.
to_s
(
:short
)
}
-
#{
to
.
to_s
(
:short
)
}
"
end
def
duration_in_numbers
(
duration
)
time_format
=
duration
<
1
.
hour
?
"%M:%S"
:
"%H:%M:%S"
def
duration_in_numbers
(
duration_in_seconds
,
allow_overflow
=
false
)
if
allow_overflow
seconds
=
duration_in_seconds
%
1
.
minute
minutes
=
(
duration_in_seconds
/
1
.
minute
)
%
(
1
.
hour
/
1
.
minute
)
hours
=
duration_in_seconds
/
1
.
hour
Time
.
at
(
duration
).
utc
.
strftime
(
time_format
)
if
hours
==
0
"%02d:%02d"
%
[
minutes
,
seconds
]
else
"%02d:%02d:%02d"
%
[
hours
,
minutes
,
seconds
]
end
else
time_format
=
duration_in_seconds
<
1
.
hour
?
"%M:%S"
:
"%H:%M:%S"
Time
.
at
(
duration_in_seconds
).
utc
.
strftime
(
time_format
)
end
end
end
app/views/projects/ci/builds/_build.html.haml
View file @
ea38e832
...
...
@@ -106,7 +106,7 @@
.btn.btn-default.has-tooltip
{
disabled:
true
,
title:
job
.
scheduled_at
}
=
sprite_icon
(
'planning'
)
=
duration_in_numbers
(
job
.
execute_in
)
=
duration_in_numbers
(
job
.
execute_in
,
true
)
.btn.btn-default.btn-build.has-tooltip
{
title:
s_
(
'DelayedJobs|Start now'
)
}
=
sprite_icon
(
'play'
)
.btn.btn-default.btn-build.has-tooltip
{
title:
s_
(
'DelayedJobs|Unschedule'
)
}
...
...
lib/gitlab/ci/status/build/scheduled.rb
View file @
ea38e832
...
...
@@ -25,9 +25,11 @@ module Gitlab
private
include
TimeHelper
def
execute_in
diff
=
[
0
,
subject
.
scheduled_at
-
Time
.
now
].
max
Time
.
at
(
diff
).
utc
.
strftime
(
"%H:%M:%S"
)
remaining_seconds
=
[
0
,
subject
.
scheduled_at
-
Time
.
now
].
max
duration_in_numbers
(
remaining_seconds
,
true
)
end
end
end
...
...
spec/helpers/time_helper_spec.rb
View file @
ea38e832
...
...
@@ -20,17 +20,35 @@ describe TimeHelper do
end
describe
"#duration_in_numbers"
do
it
"returns minutes and seconds"
do
durations_and_expectations
=
{
100
=>
"01:40"
,
121
=>
"02:01"
,
3721
=>
"01:02:01"
,
0
=>
"00:00"
,
42
=>
"00:42"
}
using
RSpec
::
Parameterized
::
TableSyntax
context
"without passing allow_overflow"
do
where
(
:duration
,
:formatted_string
)
do
0
|
"00:00"
1
.
second
|
"00:01"
42
.
seconds
|
"00:42"
2
.
minutes
+
1
.
second
|
"02:01"
3
.
hours
+
2
.
minutes
+
1
.
second
|
"03:02:01"
30
.
hours
|
"06:00:00"
end
with_them
do
it
{
expect
(
duration_in_numbers
(
duration
)).
to
eq
formatted_string
}
end
end
context
"with allow_overflow = true"
do
where
(
:duration
,
:formatted_string
)
do
0
|
"00:00"
1
.
second
|
"00:01"
42
.
seconds
|
"00:42"
2
.
minutes
+
1
.
second
|
"02:01"
3
.
hours
+
2
.
minutes
+
1
.
second
|
"03:02:01"
30
.
hours
|
"30:00:00"
end
durations_and_expectations
.
each
do
|
duration
,
expectation
|
expect
(
duration_in_numbers
(
duration
)).
to
eq
(
expectation
)
with_them
do
it
{
expect
(
duration_in_numbers
(
duration
,
true
)).
to
eq
formatted_string
}
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