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

stats page for project

parent d9680628
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -2,7 +2,7 @@ require 'runner'
 
class ProjectsController < ApplicationController
before_filter :authenticate_user!, except: [:build, :status]
before_filter :project, only: [:build, :details, :show, :status, :edit, :update, :destroy]
before_filter :project, only: [:build, :details, :show, :status, :edit, :update, :destroy, :stats]
before_filter :authenticate_token!, only: [:build]
 
def index
Loading
Loading
@@ -98,6 +98,10 @@ class ProjectsController < ApplicationController
send_file Rails.root.join('public', image_name), filename: image_name, disposition: 'inline'
end
 
def stats
end
protected
 
def project
Loading
Loading
Loading
Loading
@@ -22,4 +22,15 @@ module ProjectsHelper
def ref_tab_class ref = nil
'active' if ref == @ref
end
def success_ratio(project)
failed_builds = project.builds.failed.count
success_buids = project.builds.success.count
if failed_builds.zero?
return 100
end
(success_buids.to_f / (success_buids + failed_builds)) * 100
end
end
Loading
Loading
@@ -12,6 +12,8 @@ class Build < ActiveRecord::Base
 
scope :running, where(status: "running")
scope :pending, where(status: "pending")
scope :success, where(status: "success")
scope :failed, where(status: "failed")
 
state_machine :status, initial: :pending do
event :run do
Loading
Loading
%h3
Project: #{@project.name} &rarr; Details
Project: #{link_to @project.name, @project} &rarr; Details
- if @project.gitlab_url.present?
%small= link_to 'View on GitLab', @project.gitlab_url
.right
Loading
Loading
Loading
Loading
@@ -2,22 +2,27 @@
Project: #{@project.name}
- if @project.gitlab_url.present?
%small= link_to 'View on GitLab', @project.gitlab_url
.right
= link_to details_project_path(@project), class: 'btn btn-small' do
Details
&nbsp;
= link_to edit_project_path(@project), class: 'btn btn-small' do
%i.icon-edit.icon-white
Edit
.pull-right
%span
= link_to details_project_path(@project), class: 'btn btn-small' do
Details
%span
= link_to stats_project_path(@project), class: 'btn btn-small' do
Stats
%span
= link_to edit_project_path(@project), class: 'btn btn-small' do
%i.icon-edit.icon-white
Edit
 
 
.nav.nav-tabs
%ul.nav.nav-tabs
%li{class: ref_tab_class}
= link_to 'All builds', project_path(@project)
- @project.tracked_refs.each do |ref|
%li{class: ref_tab_class(ref)}
= link_to ref, project_path(@project, ref: ref)
 
- if @ref
%p
Paste build status image for #{@ref} with next link
Loading
Loading
%h3
Project: #{link_to @project.name, @project} &rarr; Stats
%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'
%p
Success ratio:
%strong
#{success_ratio(@project)}%
%p
Commits covered:
%strong
= @project.builds.latest_sha.count
Loading
Loading
@@ -11,6 +11,7 @@ GitlabCi::Application.routes.draw do
member do
get :run
get :status
get :stats
get :details
post :build
end
Loading
Loading
Loading
Loading
@@ -8,9 +8,20 @@ User.create(
 
 
if Rails.env == 'development'
`rm -rf #{Rails.root.join('tmp', 'test_repo')}`
`cd #{Rails.root.join('tmp')} && git clone https://github.com/randx/six.git test_repo`
 
FactoryGirl.create :project,
project = FactoryGirl.create :project,
name: "Six",
scripts: 'bundle exec rspec spec'
project.repo.commits('master', 20).each_with_index do |commit, index|
build = project.register_build(
ref: 'master',
before: commit.parents.first.id,
after: commit.id
)
Runner.perform_in(index.minutes, build.id)
end
end
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