Merge pull request #397 from warpc/223-change_build_lists_new_js_handlers
[refs #223] Add build list duration
This commit is contained in:
commit
d8edf8e673
|
@ -59,10 +59,7 @@ class BuildList < ActiveRecord::Base
|
|||
}
|
||||
|
||||
scope :recent, order("#{table_name}.updated_at DESC")
|
||||
# scope :current, lambda {
|
||||
# outdatable_statuses = [BuildServer::SUCCESS, BuildServer::ERROR, BuildServer::PLATFORM_NOT_FOUND, BuildServer::PLATFORM_PENDING, BuildServer::PROJECT_NOT_FOUND, BuildServer::PROJECT_VERSION_NOT_FOUND]
|
||||
# where(["status in (?) OR (status in (?) AND notified_at >= ?)", [WAITING_FOR_RESPONSE, BUILD_PENDING, BuildServer::BUILD_STARTED], outdatable_statuses, Time.now - 2.days])
|
||||
# }
|
||||
|
||||
scope :for_status, lambda {|status| where(:status => status) }
|
||||
scope :for_user, lambda { |user| where(:user_id => user.id) }
|
||||
scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) }
|
||||
|
@ -139,6 +136,14 @@ class BuildList < ActiveRecord::Base
|
|||
{:project => project.name, :version => project_version, :arch => arch.name}.inspect
|
||||
end
|
||||
|
||||
def human_duration
|
||||
I18n.t("layout.build_lists.human_duration", {:hours => (duration/360).to_i, :minutes => (duration/60).to_i})
|
||||
end
|
||||
|
||||
def finished?
|
||||
[BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? status
|
||||
end
|
||||
|
||||
private
|
||||
def set_default_status
|
||||
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= t("layout.#{@build_list.is_circle?}_")
|
||||
.both
|
||||
- if @build_list.finished?
|
||||
%br
|
||||
.leftside.width125
|
||||
.leftside= @build_list.human_duration
|
||||
.both
|
||||
.hr
|
||||
%h3= t("layout.build_lists.items_header")
|
||||
- if @item_groups.blank?
|
||||
|
|
|
@ -31,7 +31,7 @@ module Rosa
|
|||
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
||||
|
||||
# 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.
|
||||
# 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
|
||||
user: User
|
||||
preferences: Preferences
|
||||
started_at: Build started at
|
||||
duration: Build duration in seconds
|
||||
|
||||
build_list/item:
|
||||
name: Name
|
||||
|
@ -59,6 +61,7 @@ en:
|
|||
action: Action
|
||||
new_header: New build
|
||||
main_data: Main data
|
||||
human_duration: Builded in %{hours} h. %{minutes} min.
|
||||
|
||||
ownership:
|
||||
header: Build list ownership
|
||||
|
|
|
@ -29,6 +29,7 @@ ru:
|
|||
project_version: Версия
|
||||
user: Пользователь
|
||||
preferences: Настройки
|
||||
duration: Длительность билда в секундах
|
||||
|
||||
build_list/item:
|
||||
name: Название
|
||||
|
@ -59,6 +60,7 @@ ru:
|
|||
action: Действие
|
||||
new_header: Новая сборка
|
||||
main_data: Основные данные
|
||||
human_duration: Собрано за %{hours} ч. %{minutes} мин.
|
||||
|
||||
ownership:
|
||||
header: Принадлежность заданий
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
class CustomizePlatform < ActiveRecord::Migration
|
||||
def self.up
|
||||
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, :released, false
|
||||
change_column_null :platforms, :visibility, false
|
||||
|
|
|
@ -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.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120404134602) do
|
||||
ActiveRecord::Schema.define(:version => 20120411142354) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.string "kind"
|
||||
t.text "data"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
|
@ -75,6 +75,8 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
|||
t.string "package_version"
|
||||
t.string "commit_hash"
|
||||
t.integer "priority", :default => 0, :null => false
|
||||
t.datetime "started_at"
|
||||
t.integer "duration"
|
||||
end
|
||||
|
||||
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 "visibility", :default => "open", :null => false
|
||||
t.string "platform_type", :default => "main", :null => false
|
||||
t.string "distrib_type", :null => false
|
||||
t.string "distrib_type"
|
||||
end
|
||||
|
||||
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.string "ancestry"
|
||||
t.boolean "has_issues", :default => true
|
||||
t.boolean "has_wiki", :default => false
|
||||
t.string "srpm_file_name"
|
||||
t.string "srpm_content_type"
|
||||
t.integer "srpm_file_size"
|
||||
t.datetime "srpm_updated_at"
|
||||
t.boolean "has_wiki", :default => false
|
||||
t.string "default_branch", :default => "master"
|
||||
t.boolean "is_rpm", :default => true
|
||||
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|
|
||||
t.string "name"
|
||||
t.string "email"
|
||||
t.string "token"
|
||||
t.boolean "approved", :default => false
|
||||
t.boolean "rejected", :default => false
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "interest"
|
||||
t.text "more"
|
||||
end
|
||||
|
@ -331,16 +331,19 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
|||
t.string "name"
|
||||
t.string "email", :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.datetime "remember_created_at"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.text "ssh_key"
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
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.datetime "reset_password_sent_at"
|
||||
t.text "professional_experience"
|
||||
t.string "site"
|
||||
t.string "company"
|
||||
|
@ -352,9 +355,6 @@ ActiveRecord::Schema.define(:version => 20120404134602) do
|
|||
t.integer "failed_attempts", :default => 0
|
||||
t.string "unlock_token"
|
||||
t.datetime "locked_at"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
end
|
||||
|
||||
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