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
973e4030
Commit
973e4030
authored
Mar 22, 2018
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor build_metadata
parent
7d7b0688
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
28 deletions
+25
-28
app/assets/javascripts/jobs/components/sidebar_details_block.vue
...ets/javascripts/jobs/components/sidebar_details_block.vue
+9
-3
app/models/ci/build.rb
app/models/ci/build.rb
+1
-1
app/models/ci/build_metadata.rb
app/models/ci/build_metadata.rb
+4
-12
app/serializers/build_details_entity.rb
app/serializers/build_details_entity.rb
+1
-3
spec/factories/ci/build_metadata.rb
spec/factories/ci/build_metadata.rb
+9
-0
spec/models/ci/build_metadata_spec.rb
spec/models/ci/build_metadata_spec.rb
+1
-9
No files found.
app/assets/javascripts/jobs/components/sidebar_details_block.vue
View file @
973e4030
...
...
@@ -44,10 +44,16 @@
runnerId
()
{
return
`#
${
this
.
job
.
runner
.
id
}
`
;
},
hasTimeout
()
{
return
this
.
job
.
metadata
!=
null
&&
this
.
job
.
metadata
.
timeout_human_readable
!==
''
;
},
timeout
()
{
let
t
=
`
${
this
.
job
.
metadata
.
timeout_human_readable
}
`
;
if
(
this
.
job
.
metadata
==
null
)
{
return
''
;
}
if
(
this
.
job
.
metadata
.
timeout_source
!=
null
)
{
let
t
=
this
.
job
.
metadata
.
timeout_human_readable
;
if
(
this
.
job
.
metadata
.
timeout_source
!==
''
)
{
t
+=
` (from
${
this
.
job
.
metadata
.
timeout_source
}
)`
;
}
...
...
@@ -130,7 +136,7 @@
/>
<detail-row
class=
"js-job-timeout"
v-if=
"
job.metadata.timeout_human_readable
"
v-if=
"
hasTimeout
"
title=
"Timeout"
:help-url=
"runnerHelpUrl"
:value=
"timeout"
...
...
app/models/ci/build.rb
View file @
973e4030
...
...
@@ -162,7 +162,7 @@ module Ci
end
def
ensure_metadata
metadata
||
build_metadata
metadata
||
build_metadata
(
project:
project
)
end
def
detailed_status
(
current_user
)
...
...
app/models/ci/build_metadata.rb
View file @
973e4030
...
...
@@ -11,9 +11,9 @@ module Ci
belongs_to
:build
,
class_name:
'Ci::Build'
belongs_to
:project
chronic_duration_attr_reader
:timeout_human_readable
,
:timeout
validates
:project
,
presence:
true
after_initialize
:set_project_id
chronic_duration_attr_reader
:timeout_human_readable
,
:timeout
enum
timeout_source:
{
unknown_timeout_source:
1
,
...
...
@@ -24,19 +24,11 @@ module Ci
def
save_timeout_state!
return
unless
build
.
runner
.
present?
project_timeout
=
build
.
project
&
.
build_timeout
project_timeout
=
project
&
.
build_timeout
timeout
=
[
project_timeout
,
build
.
runner
.
maximum_timeout
].
compact
.
min
timeout_source
=
timeout
<
project_timeout
?
:runner_timeout_source
:
:project_timeout_source
update_attributes
(
timeout:
timeout
,
timeout_source:
timeout_source
)
end
private
def
set_project_id
return
unless
self
.
project_id
.
nil?
self
.
project_id
=
build
&
.
project
&
.
id
update!
(
timeout:
timeout
,
timeout_source:
timeout_source
)
end
end
end
app/serializers/build_details_entity.rb
View file @
973e4030
...
...
@@ -5,9 +5,7 @@ class BuildDetailsEntity < JobEntity
expose
:runner
,
using:
RunnerEntity
expose
:pipeline
,
using:
PipelineEntity
expose
:metadata
,
using:
BuildMetadataEntity
do
|
build
|
build
.
ensure_metadata
end
expose
:metadata
,
using:
BuildMetadataEntity
expose
:erased_by
,
if:
->
(
*
)
{
build
.
erased?
},
using:
UserEntity
expose
:erase_path
,
if:
->
(
*
)
{
build
.
erasable?
&&
can?
(
current_user
,
:erase_build
,
build
)
}
do
|
build
|
...
...
spec/factories/ci/build_metadata.rb
0 → 100644
View file @
973e4030
FactoryBot
.
define
do
factory
:ci_build_metadata
,
class:
Ci
::
BuildMetadata
do
build
factory: :ci_build
after
(
:build
)
do
|
build_metadata
,
_
|
build_metadata
.
project
||=
build_metadata
.
build
.
project
end
end
end
spec/models/ci/build_metadata_spec.rb
View file @
973e4030
...
...
@@ -13,15 +13,7 @@ describe Ci::BuildMetadata do
end
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:build_metadata
)
{
described_class
.
create
(
build:
build
)
}
context
'when creating'
do
subject
{
build_metadata
.
project_id
}
it
'saves project_id'
do
is_expected
.
to
eq
(
project
.
id
)
end
end
let
(
:build_metadata
)
{
create
(
:ci_build_metadata
,
build:
build
)
}
describe
'#save_timeout_state!'
do
subject
{
build_metadata
}
...
...
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