Merge branch 'master' into cd-v3-parity
Keeping my branch up to date with the master
This commit is contained in:
commit
9d7a01e60c
|
@ -20,6 +20,16 @@ module Travis::API::V3
|
||||||
read_attribute(:branch)
|
read_attribute(:branch)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def job_ids
|
||||||
|
return super unless cached = cached_matrix_ids
|
||||||
|
|
||||||
|
# AR 3.2 does not handle pg arrays and the plugins supporting them
|
||||||
|
# do not work well with jdbc drivers
|
||||||
|
# TODO: remove this once we're on >= 4.0
|
||||||
|
cached = cached.gsub(/^{|}$/, '').split(',').map(&:to_i) unless cached.is_a? Array
|
||||||
|
cached
|
||||||
|
end
|
||||||
|
|
||||||
def branch_name=(value)
|
def branch_name=(value)
|
||||||
write_attribute(:branch, value)
|
write_attribute(:branch, value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,6 +15,7 @@ module Travis::API::V3
|
||||||
|
|
||||||
list = list.includes(:commit).includes(branch: :last_build).includes(:repository)
|
list = list.includes(:commit).includes(branch: :last_build).includes(:repository)
|
||||||
list = list.includes(branch: { last_build: :commit }) if includes? 'build.commit'.freeze
|
list = list.includes(branch: { last_build: :commit }) if includes? 'build.commit'.freeze
|
||||||
|
list = list.includes(:jobs) if includes? 'build.jobs'.freeze or includes? 'job'.freeze
|
||||||
list
|
list
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,5 +4,25 @@ module Travis::API::V3
|
||||||
class Renderer::Build < Renderer::ModelRenderer
|
class Renderer::Build < Renderer::ModelRenderer
|
||||||
representation(:minimal, :id, :number, :state, :duration, :event_type, :previous_state, :started_at, :finished_at, :jobs)
|
representation(:minimal, :id, :number, :state, :duration, :event_type, :previous_state, :started_at, :finished_at, :jobs)
|
||||||
representation(:standard, *representations[:minimal], :repository, :branch, :commit)
|
representation(:standard, *representations[:minimal], :repository, :branch, :commit)
|
||||||
|
|
||||||
|
def jobs
|
||||||
|
return model.jobs if include_full_jobs?
|
||||||
|
model.job_ids.map { |id| job(id) }
|
||||||
|
end
|
||||||
|
|
||||||
|
private def include_full_jobs?
|
||||||
|
return true if include? 'build.job'.freeze
|
||||||
|
return true if include.any? { |i| i.start_with? 'job.'.freeze }
|
||||||
|
return true if included.any? { |i| i.is_a? Models::Job and i.source_id == model.id }
|
||||||
|
end
|
||||||
|
|
||||||
|
private def job(id)
|
||||||
|
{
|
||||||
|
"@type" => "job",
|
||||||
|
:@href => Renderer.href(:job, script_name: script_name, id: id),
|
||||||
|
"@representation" => "minimal",
|
||||||
|
"id" => id
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user