diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-04-09 11:38:07 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-04-09 11:38:07 +0300 |
commit | 62318bc66d314546841618349c0df66afdb98f87 (patch) | |
tree | a6f42c7d45c4600eed98fabb26ca4634a278a016 | |
parent | 0e0a6a2e2b2dd8358458d79b80d0fef64b12bb7c (diff) | |
download | gitlab-ci-62318bc66d314546841618349c0df66afdb98f87.tar.gz |
remove latest_sha scope
-rw-r--r-- | app/models/build.rb | 5 | ||||
-rw-r--r-- | app/models/project.rb | 2 | ||||
-rw-r--r-- | app/views/projects/stats.html.haml | 4 |
3 files changed, 5 insertions, 6 deletions
diff --git a/app/models/build.rb b/app/models/build.rb index 4d4df83..4f4d17f 100644 --- a/app/models/build.rb +++ b/app/models/build.rb @@ -8,12 +8,11 @@ class Build < ActiveRecord::Base validates :ref, presence: true validates :status, presence: true - scope :latest_sha, where("id IN(SELECT MAX(id) FROM #{self.table_name} group by sha)") - scope :running, ->() { where(status: "running") } scope :pending, ->() { where(status: "pending") } scope :success, ->() { where(status: "success") } - scope :failed, ->() { where(status: "failed") } + scope :failed, ->() { where(status: "failed") } + scope :uniq_sha, ->() { select('DISTINCT(sha)') } def self.last_month where('created_at > ?', Date.today - 1.month) diff --git a/app/models/project.rb b/app/models/project.rb index ce4df22..991b41c 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -81,7 +81,7 @@ class Project < ActiveRecord::Base end def status_image ref = 'master' - build = self.builds.where(ref: ref).latest_sha.last + build = self.builds.where(ref: ref).last image_for_build build end diff --git a/app/views/projects/stats.html.haml b/app/views/projects/stats.html.haml index e6c4e12..0e977cd 100644 --- a/app/views/projects/stats.html.haml +++ b/app/views/projects/stats.html.haml @@ -24,7 +24,7 @@ %p Commits covered: %strong - = @project.builds.last_month.latest_sha.count + = @project.builds.last_month.uniq_sha.count .span6 %fieldset @@ -47,5 +47,5 @@ %p Commits covered: %strong - = @project.builds.latest_sha.count + = @project.builds.uniq_sha.count |