[Refs #223] Refactoring for pull request
This commit is contained in:
parent
8ffc6be347
commit
100a166699
|
@ -7,6 +7,15 @@ class BuildListObserver < ActiveRecord::Observer
|
||||||
if [BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? record.status
|
if [BuildServer::BUILD_ERROR, BuildServer::SUCCESS].include? record.status
|
||||||
# stores time interval beetwin build start and finish in seconds
|
# stores time interval beetwin build start and finish in seconds
|
||||||
record.duration = record.current_duration
|
record.duration = record.current_duration
|
||||||
|
|
||||||
|
if record.status == BuildServer::SUCCESS
|
||||||
|
# Update project average build time
|
||||||
|
av_time = record.project.average_build_time
|
||||||
|
n = record.project.build_count
|
||||||
|
new_av_time = ( av_time * n + record.duration ) / ( n + 1 )
|
||||||
|
record.project.update_attribute(:average_build_time, new_av_time)
|
||||||
|
record.project.update_attribute(:build_count, n + 1 )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -203,13 +203,9 @@ class Project < ActiveRecord::Base
|
||||||
recipients
|
recipients
|
||||||
end
|
end
|
||||||
|
|
||||||
def average_build_time
|
|
||||||
build_lists.where(:status => BuildServer::SUCCESS).average(:duration)
|
|
||||||
end
|
|
||||||
|
|
||||||
def human_average_build_time
|
def human_average_build_time
|
||||||
time = average_build_time
|
time = average_build_time
|
||||||
I18n.t("layout.projects.human_average_build_time", :minutes => (time/60).to_i, :seconds => (time%60).to_i)
|
I18n.t("layout.projects.human_average_build_time", {:hours => (time/360).to_i, :minutes => (time/60).to_i})
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -60,10 +60,8 @@
|
||||||
- if !@build_list.finished? && @build_list.started_at
|
- if !@build_list.finished? && @build_list.started_at
|
||||||
%br
|
%br
|
||||||
.leftside.width125
|
.leftside.width125
|
||||||
.leftside= @build_list.human_current_duration
|
.leftside
|
||||||
.both
|
= "#{@build_list.human_current_duration} / #{@build_list.project.human_average_build_time}"
|
||||||
.leftside.width125
|
|
||||||
.leftside= @build_list.project.human_average_build_time
|
|
||||||
.both
|
.both
|
||||||
|
|
||||||
.hr
|
.hr
|
||||||
|
|
|
@ -33,7 +33,7 @@ en:
|
||||||
sections: Sections
|
sections: Sections
|
||||||
has_issue_description: Tracker adds a lightweight issue management system tightly integrated with your repository.
|
has_issue_description: Tracker adds a lightweight issue management system tightly integrated with your repository.
|
||||||
has_wiki_description: Wikis are the simplest way to allow other users to contribute content. Any user can create and edit pages for documentation, examples, support or anything you wish.
|
has_wiki_description: Wikis are the simplest way to allow other users to contribute content. Any user can create and edit pages for documentation, examples, support or anything you wish.
|
||||||
human_average_build_time: Average build time is %{minutes} minutes %{seconds} seconds
|
human_average_build_time: Expected time is %{hours} h. %{minutes} min.
|
||||||
|
|
||||||
git_help:
|
git_help:
|
||||||
cloning: Cloning the repository
|
cloning: Cloning the repository
|
||||||
|
|
|
@ -33,7 +33,7 @@ ru:
|
||||||
sections: Разделы
|
sections: Разделы
|
||||||
has_issue_description: Трэкер предоставляет лекговесный менеджер для задач по разработке Вашего проекта.
|
has_issue_description: Трэкер предоставляет лекговесный менеджер для задач по разработке Вашего проекта.
|
||||||
has_wiki_description: Wiki - это самый простой способ предоставить другим вносить свой вклад в развитие Вашего проекта. Каждый пользователь нашего сервиса может использовать Wiki для документирования, примеров, поддержки или всего другого, в чем у Вас появится необходимость.
|
has_wiki_description: Wiki - это самый простой способ предоставить другим вносить свой вклад в развитие Вашего проекта. Каждый пользователь нашего сервиса может использовать Wiki для документирования, примеров, поддержки или всего другого, в чем у Вас появится необходимость.
|
||||||
human_average_build_time: Среднее время сборки %{minutes} минут %{seconds} секунд
|
human_average_build_time: 'Ожидаемое время: %{hours} ч. %{minutes} мин.'
|
||||||
|
|
||||||
diff_show_header: "%{files} с %{additions} и %{deletions}."
|
diff_show_header: "%{files} с %{additions} и %{deletions}."
|
||||||
about_subheader: "О проекте"
|
about_subheader: "О проекте"
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
class BuildAverageTime < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :projects, :average_build_time, :integer, :null => false, :default => 0
|
||||||
|
add_column :projects, :build_count, :integer, :null => false, :default => 0
|
||||||
|
end
|
||||||
|
end
|
20
db/schema.rb
20
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# 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 => 20120411142354) do
|
ActiveRecord::Schema.define(:version => 20120413102757) 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
|
||||||
|
@ -190,7 +190,7 @@ ActiveRecord::Schema.define(:version => 20120411142354) 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"
|
t.string "distrib_type", :null => false
|
||||||
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
|
||||||
|
@ -261,23 +261,27 @@ ActiveRecord::Schema.define(:version => 20120411142354) 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
|
||||||
|
t.integer "average_build_time", :default => 0, :null => false
|
||||||
|
t.integer "build_count", :default => 0, :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true
|
||||||
|
|
||||||
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", :null => false
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at"
|
||||||
t.string "interest"
|
t.string "interest"
|
||||||
t.text "more"
|
t.text "more"
|
||||||
end
|
end
|
||||||
|
@ -339,9 +343,6 @@ ActiveRecord::Schema.define(:version => 20120411142354) do
|
||||||
t.string "uname"
|
t.string "uname"
|
||||||
t.string "role"
|
t.string "role"
|
||||||
t.string "language", :default => "en"
|
t.string "language", :default => "en"
|
||||||
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.datetime "reset_password_sent_at"
|
||||||
t.text "professional_experience"
|
t.text "professional_experience"
|
||||||
|
@ -355,6 +356,9 @@ ActiveRecord::Schema.define(:version => 20120411142354) 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
|
||||||
|
|
Loading…
Reference in New Issue