Skip to content

Commit 036b5be

Browse files
committed
Add restarter to job
1 parent 4864236 commit 036b5be

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/travis/api/v3/models/job.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class Models::Job < Model
1414
belongs_to :stage
1515
belongs_to :owner, polymorphic: true
1616
belongs_to :config, foreign_key: :config_id, class_name: Models::JobConfig
17+
belongs_to :restarter, foreign_key: :restarted_by, polymorphic: true, class_name: Models::User
1718
serialize :config
1819
serialize :debug_options
1920

lib/travis/api/v3/renderer/job.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
module Travis::API::V3
44
class Renderer::Job < ModelRenderer
55
representation(:minimal, :id)
6-
representation(:standard, *representations[:minimal], :allow_failure, :number, :state, :started_at, :finished_at, :build, :queue, :repository, :commit, :owner, :stage, :created_at, :updated_at, :private)
6+
representation(:standard, *representations[:minimal], :allow_failure, :number, :state, :started_at, :finished_at, :build, :queue, :repository, :commit, :owner, :stage, :created_at, :updated_at, :private, :restarted_at, :restarted_by)
77
representation(:active, *representations[:standard])
88

99
# TODO: I don't want to config be visible in the regular representation
1010
# as I want it to be visible only after adding include=job.config
1111
# we probably need to have a better way of doing this
12-
representation(:with_config, *representations[:minimal], :allow_failure, :number, :state, :started_at, :finished_at, :build, :queue, :repository, :commit, :owner, :stage, :created_at, :updated_at, :config)
12+
representation(:with_config, *representations[:minimal], :allow_failure, :number, :state, :started_at, :finished_at, :build, :queue, :repository, :commit, :owner, :stage, :created_at, :updated_at, :restarted_at, :restarted_by, :config)
1313

1414
hidden_representations(:with_config)
1515
hidden_representations(:active)
@@ -26,6 +26,16 @@ def updated_at
2626
json_format_time_with_ms(model.updated_at)
2727
end
2828

29+
def restarted_by
30+
return nil unless restarter = model.restarter
31+
{
32+
'@type' => 'user',
33+
'@representation' => 'minimal'.freeze,
34+
'id' => restarter.id,
35+
'login' => restarter.login
36+
}
37+
end
38+
2939
def config
3040
if include_config?
3141
ConfigObfuscator.new(model.config, model.repository.key).obfuscate

0 commit comments

Comments
 (0)