[refs #223] Add build list duration
This commit is contained in:
parent
4ba17be536
commit
742603ab7e
|
@ -139,6 +139,14 @@ class BuildList < ActiveRecord::Base
|
||||||
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def human_duration
|
||||||
|
I18n.t("layout.build_lists.human_duration", {:minutes => (duration/60).to_i, :seconds => (duration%60).to_i})
|
||||||
|
end
|
||||||
|
|
||||||
|
def finished?
|
||||||
|
[BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? status
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def set_default_status
|
def set_default_status
|
||||||
self.status = WAITING_FOR_RESPONSE unless self.status.present?
|
self.status = WAITING_FOR_RESPONSE unless self.status.present?
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
class BuildListObserver < ActiveRecord::Observer
|
||||||
|
observe :build_list
|
||||||
|
|
||||||
|
def before_update(record)
|
||||||
|
if record.status_changed?
|
||||||
|
record.started_at = Time.now if record.status == BuildServer::BUILD_STARTED
|
||||||
|
if [BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? record.status
|
||||||
|
# stores time interval beetwin build start and finish in seconds
|
||||||
|
record.duration = (Time.now - record.started_at).to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -52,6 +52,11 @@
|
||||||
.leftside.width125= t("activerecord.attributes.build_list.is_circle")
|
.leftside.width125= t("activerecord.attributes.build_list.is_circle")
|
||||||
.leftside= t("layout.#{@build_list.is_circle?}_")
|
.leftside= t("layout.#{@build_list.is_circle?}_")
|
||||||
.both
|
.both
|
||||||
|
- if @build_list.finished?
|
||||||
|
%br
|
||||||
|
.leftside.width125
|
||||||
|
.leftside= @build_list.human_duration
|
||||||
|
.both
|
||||||
.hr
|
.hr
|
||||||
%h3= t("layout.build_lists.items_header")
|
%h3= t("layout.build_lists.items_header")
|
||||||
- if @item_groups.blank?
|
- if @item_groups.blank?
|
||||||
|
|
|
@ -31,7 +31,7 @@ module Rosa
|
||||||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||||
|
|
||||||
# Activate observers that should always be running.
|
# Activate observers that should always be running.
|
||||||
config.active_record.observers = :event_log_observer, :activity_feed_observer
|
config.active_record.observers = :event_log_observer, :activity_feed_observer, :build_list_observer
|
||||||
|
|
||||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||||
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
||||||
|
|
|
@ -29,6 +29,8 @@ en:
|
||||||
project_version: Version
|
project_version: Version
|
||||||
user: User
|
user: User
|
||||||
preferences: Preferences
|
preferences: Preferences
|
||||||
|
started_at: Build started at
|
||||||
|
duration: Build duration in seconds
|
||||||
|
|
||||||
build_list/item:
|
build_list/item:
|
||||||
name: Name
|
name: Name
|
||||||
|
@ -59,6 +61,7 @@ en:
|
||||||
action: Action
|
action: Action
|
||||||
new_header: New build
|
new_header: New build
|
||||||
main_data: Main data
|
main_data: Main data
|
||||||
|
human_duration: Build lasted %{minutes} minutes %{seconds} seconds
|
||||||
|
|
||||||
ownership:
|
ownership:
|
||||||
header: Build list ownership
|
header: Build list ownership
|
||||||
|
|
|
@ -29,6 +29,7 @@ ru:
|
||||||
project_version: Версия
|
project_version: Версия
|
||||||
user: Пользователь
|
user: Пользователь
|
||||||
preferences: Настройки
|
preferences: Настройки
|
||||||
|
duration: Длительность билда в секундах
|
||||||
|
|
||||||
build_list/item:
|
build_list/item:
|
||||||
name: Название
|
name: Название
|
||||||
|
@ -59,6 +60,7 @@ ru:
|
||||||
action: Действие
|
action: Действие
|
||||||
new_header: Новая сборка
|
new_header: Новая сборка
|
||||||
main_data: Основные данные
|
main_data: Основные данные
|
||||||
|
human_duration: Сборка продлилась %{minutes} минут %{seconds} секунд
|
||||||
|
|
||||||
ownership:
|
ownership:
|
||||||
header: Принадлежность заданий
|
header: Принадлежность заданий
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
class CustomizePlatform < ActiveRecord::Migration
|
class CustomizePlatform < ActiveRecord::Migration
|
||||||
def self.up
|
def self.up
|
||||||
change_column_null :platforms, :name, false
|
change_column_null :platforms, :name, false
|
||||||
change_column_null :platforms, :distrib_type, false
|
#change_column_null :platforms, :distrib_type, false
|
||||||
change_column_null :platforms, :platform_type, false
|
change_column_null :platforms, :platform_type, false
|
||||||
change_column_null :platforms, :released, false
|
change_column_null :platforms, :released, false
|
||||||
change_column_null :platforms, :visibility, false
|
change_column_null :platforms, :visibility, false
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddStartedAtAndFinishedAtToBuildLists < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :build_lists, :started_at, :datetime
|
||||||
|
add_column :build_lists, :finished_at, :datetime
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
class RemoveUnusedFields < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
remove_column :build_lists, :started_at
|
||||||
|
remove_column :build_lists, :finished_at
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,6 @@
|
||||||
|
class AddStartedAtAndDurationToBuildLists < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :build_lists, :started_at, :datetime
|
||||||
|
add_column :build_lists, :duration, :integer
|
||||||
|
end
|
||||||
|
end
|
28
db/schema.rb
28
db/schema.rb
|
@ -11,14 +11,14 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20120404134602) do
|
ActiveRecord::Schema.define(:version => 20120411142354) do
|
||||||
|
|
||||||
create_table "activity_feeds", :force => true do |t|
|
create_table "activity_feeds", :force => true do |t|
|
||||||
t.integer "user_id", :null => false
|
t.integer "user_id", :null => false
|
||||||
t.string "kind"
|
t.string "kind"
|
||||||
t.text "data"
|
t.text "data"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "arches", :force => true do |t|
|
create_table "arches", :force => true do |t|
|
||||||
|
@ -75,6 +75,8 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
||||||
t.string "package_version"
|
t.string "package_version"
|
||||||
t.string "commit_hash"
|
t.string "commit_hash"
|
||||||
t.integer "priority", :default => 0, :null => false
|
t.integer "priority", :default => 0, :null => false
|
||||||
|
t.datetime "started_at"
|
||||||
|
t.integer "duration"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
|
||||||
|
@ -188,7 +190,7 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
||||||
t.string "owner_type"
|
t.string "owner_type"
|
||||||
t.string "visibility", :default => "open", :null => false
|
t.string "visibility", :default => "open", :null => false
|
||||||
t.string "platform_type", :default => "main", :null => false
|
t.string "platform_type", :default => "main", :null => false
|
||||||
t.string "distrib_type", :null => false
|
t.string "distrib_type"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
|
add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false
|
||||||
|
@ -259,25 +261,23 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
||||||
t.text "description"
|
t.text "description"
|
||||||
t.string "ancestry"
|
t.string "ancestry"
|
||||||
t.boolean "has_issues", :default => true
|
t.boolean "has_issues", :default => true
|
||||||
|
t.boolean "has_wiki", :default => false
|
||||||
t.string "srpm_file_name"
|
t.string "srpm_file_name"
|
||||||
t.string "srpm_content_type"
|
t.string "srpm_content_type"
|
||||||
t.integer "srpm_file_size"
|
t.integer "srpm_file_size"
|
||||||
t.datetime "srpm_updated_at"
|
t.datetime "srpm_updated_at"
|
||||||
t.boolean "has_wiki", :default => false
|
|
||||||
t.string "default_branch", :default => "master"
|
t.string "default_branch", :default => "master"
|
||||||
t.boolean "is_rpm", :default => true
|
t.boolean "is_rpm", :default => true
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true, :case_sensitive => false
|
|
||||||
|
|
||||||
create_table "register_requests", :force => true do |t|
|
create_table "register_requests", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.string "token"
|
t.string "token"
|
||||||
t.boolean "approved", :default => false
|
t.boolean "approved", :default => false
|
||||||
t.boolean "rejected", :default => false
|
t.boolean "rejected", :default => false
|
||||||
t.datetime "created_at"
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at", :null => false
|
||||||
t.string "interest"
|
t.string "interest"
|
||||||
t.text "more"
|
t.text "more"
|
||||||
end
|
end
|
||||||
|
@ -331,16 +331,19 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "email", :default => "", :null => false
|
t.string "email", :default => "", :null => false
|
||||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||||
|
t.string "password_salt", :default => "", :null => false
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.text "ssh_key"
|
|
||||||
t.string "uname"
|
t.string "uname"
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
t.datetime "reset_password_sent_at"
|
t.string "confirmation_token"
|
||||||
|
t.datetime "confirmed_at"
|
||||||
|
t.datetime "confirmation_sent_at"
|
||||||
t.integer "own_projects_count", :default => 0, :null => false
|
t.integer "own_projects_count", :default => 0, :null => false
|
||||||
|
t.datetime "reset_password_sent_at"
|
||||||
t.text "professional_experience"
|
t.text "professional_experience"
|
||||||
t.string "site"
|
t.string "site"
|
||||||
t.string "company"
|
t.string "company"
|
||||||
|
@ -352,9 +355,6 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
||||||
t.integer "failed_attempts", :default => 0
|
t.integer "failed_attempts", :default => 0
|
||||||
t.string "unlock_token"
|
t.string "unlock_token"
|
||||||
t.datetime "locked_at"
|
t.datetime "locked_at"
|
||||||
t.string "confirmation_token"
|
|
||||||
t.datetime "confirmed_at"
|
|
||||||
t.datetime "confirmation_sent_at"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe BuildListObserver do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
Loading…
Reference in New Issue