diff options
| author | Regis <boudinot.regis@yahoo.com> | 2017-01-02 16:24:37 -0700 |
|---|---|---|
| committer | Regis <boudinot.regis@yahoo.com> | 2017-01-02 16:24:37 -0700 |
| commit | 0a074f2e091d8b2f1bce49e50ecf69b667c62dc2 (patch) | |
| tree | 314027556f06514278a4f83f35813c00b2d5418f /app/models/ci | |
| parent | 588219352c99213d099aff72f32d6ad9ec4830d4 (diff) | |
| parent | de25604fbca2f7005754d821d571bbcb1cc510ac (diff) | |
| download | gitlab-ce-0a074f2e091d8b2f1bce49e50ecf69b667c62dc2.tar.gz | |
fix pipelines/index.html.haml merge conflict
Diffstat (limited to 'app/models/ci')
| -rw-r--r-- | app/models/ci/build.rb | 6 | ||||
| -rw-r--r-- | app/models/ci/pipeline.rb | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index cb76cdf5981..27042798741 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -43,6 +43,8 @@ module Ci before_destroy { project } after_create :execute_hooks + after_save :update_project_statistics, if: :artifacts_size_changed? + after_destroy :update_project_statistics class << self def first_pending @@ -584,5 +586,9 @@ module Ci Ci::MaskSecret.mask!(trace, token) trace end + + def update_project_statistics + ProjectCacheWorker.perform_async(project_id, [], [:build_artifacts_size]) + end end end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 1814469f6ce..2a97e8bae4a 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -93,11 +93,8 @@ module Ci .select("max(#{quoted_table_name}.id)") .group(:ref, :sha) - if ref - where(id: max_id, ref: ref) - else - where(id: max_id) - end + relation = ref ? where(ref: ref) : self + relation.where(id: max_id) end def self.latest_status(ref = nil) @@ -105,7 +102,7 @@ module Ci end def self.latest_successful_for(ref) - success.latest(ref).first + success.latest(ref).order(id: :desc).first end def self.truncate_sha(sha) |
