diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-28 14:58:53 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-07-28 14:58:53 +0200 |
commit | 0c4fa8619ca477c0a78c825df8dd38cd2a109644 (patch) | |
tree | c48ff9bd346e8135542eb2ee2f246de899d20ae3 /lib/gitlab/badge | |
parent | 9ae1ecf876e40ce9dd64c72e025f32e38c882fd6 (diff) | |
download | gitlab-ce-0c4fa8619ca477c0a78c825df8dd38cd2a109644.tar.gz |
Calculate build status only in build badge class
Diffstat (limited to 'lib/gitlab/badge')
-rw-r--r-- | lib/gitlab/badge/build.rb | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/gitlab/badge/build.rb b/lib/gitlab/badge/build.rb index 21d60854bf5..7bc6f285ce1 100644 --- a/lib/gitlab/badge/build.rb +++ b/lib/gitlab/badge/build.rb @@ -5,8 +5,16 @@ module Gitlab # class Build def initialize(project, ref) - @project, @ref = project, ref - @image = ::Ci::ImageForBuildService.new.execute(project, ref: ref) + @project = project + @ref = ref + end + + def status + sha = @project.commit(@ref).try(:sha) + + @project.pipelines + .where(sha: sha, ref: @ref) + .status || 'unknown' end def metadata @@ -18,11 +26,9 @@ module Gitlab end def data - File.read(@image[:path]) - end - - def to_s - @image[:name].sub(/\.svg$/, '') + File.read( + Rails.root.join('public/ci', 'build-' + status + '.svg') + ) end end end |