Skip to content
Snippets Groups Projects
Commit 9f40af47 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

more stats. Show link to build on projects page

parent f45d6436
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -28,4 +28,8 @@ module BuildsHelper
build.short_sha
end
end
def build_link build
link_to(build.short_sha, project_build_path(build.project, build))
end
end
Loading
Loading
@@ -23,14 +23,13 @@ module ProjectsHelper
'active' if ref == @ref
end
 
def success_ratio(project)
failed_builds = project.builds.failed.count
success_buids = project.builds.success.count
def success_ratio(success_builds, failed_builds)
failed_builds = failed_builds.count
success_builds = success_builds.count
 
if failed_builds.zero?
return 100
end
return 100 if failed_builds.zero?
 
(success_buids.to_f / (success_buids + failed_builds)) * 100
ratio = (success_builds.to_f / (success_builds + failed_builds)) * 100
ratio.to_i
end
end
Loading
Loading
@@ -10,10 +10,14 @@ class Build < ActiveRecord::Base
 
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 :running, ->() { where(status: "running") }
scope :pending, ->() { where(status: "pending") }
scope :success, ->() { where(status: "success") }
scope :failed, ->() { where(status: "failed") }
def self.last_month
where('created_at > ?', Date.today - 1.month)
end
 
state_machine :status, initial: :pending do
event :run do
Loading
Loading
%h3 Projects
- @projects.each do |project|
- last_build = project.last_build
.project_box
.title
= link_to project do
%strong= project.name
.alert{class: project_statuc_class(project) }
- if project.last_build
#{project.human_status}
- if last_build
#{last_build.status} (#{build_link(last_build)})
.right
= time_ago_in_words project.last_build_date
ago
Loading
Loading
Loading
Loading
@@ -3,24 +3,49 @@
 
%p.lead Some stats related to the project
 
%fieldset
%legend Builds
%p
Total:
%strong= pluralize @project.builds.count, 'build'
%p
Successful:
%strong= pluralize @project.builds.success.count, 'build'
%p
Failed:
%strong= pluralize @project.builds.failed.count, 'build'
.row-fluid
.span6
%fieldset
%legend Last month
%p
Total:
%strong= pluralize @project.builds.last_month.count, 'build'
%p
Successful:
%strong= pluralize @project.builds.last_month.success.count, 'build'
%p
Failed:
%strong= pluralize @project.builds.last_month.failed.count, 'build'
 
%p
Success ratio:
%strong
#{success_ratio(@project)}%
%p
Success ratio:
%strong
#{success_ratio(@project.builds.last_month.success, @project.builds.last_month.failed)}%
%p
Commits covered:
%strong
= @project.builds.last_month.latest_sha.count
.span6
%fieldset
%legend Overall
%p
Total:
%strong= pluralize @project.builds.count, 'build'
%p
Successful:
%strong= pluralize @project.builds.success.count, 'build'
%p
Failed:
%strong= pluralize @project.builds.failed.count, 'build'
%p
Success ratio:
%strong
#{success_ratio(@project.builds.success, @project.builds.failed)}%
%p
Commits covered:
%strong
= @project.builds.latest_sha.count
 
%p
Commits covered:
%strong
= @project.builds.latest_sha.count
Loading
Loading
@@ -19,8 +19,8 @@ ActiveRecord::Schema.define(:version => 20130129121754) do
t.string "status"
t.datetime "finished_at"
t.text "trace"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "sha"
t.datetime "started_at"
t.string "tmp_file"
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment