[#360] remove mass build cached counters

This commit is contained in:
Alexander Machehin 2014-02-24 20:28:48 +06:00
parent c755ec6acb
commit 0e8f6321fb
6 changed files with 36 additions and 25 deletions

View File

@ -142,21 +142,6 @@ class BuildList < ActiveRecord::Base
state_machine :status, initial: :waiting_for_response do
# WTF? around_transition -> infinite loop
before_transition do |build_list, transition|
status = HUMAN_STATUSES[build_list.status]
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
MassBuild.decrement_counter "#{status.to_s}_count", build_list.mass_build_id
end
end
after_transition do |build_list, transition|
status = HUMAN_STATUSES[build_list.status]
if build_list.mass_build && MassBuild::COUNT_STATUSES.include?(status)
MassBuild.increment_counter "#{status.to_s}_count", build_list.mass_build_id
end
end
after_transition(on: :place_build) do |build_list, transition|
build_list.add_job_to_abf_worker_queue if build_list.external_nodes.blank?
end

View File

@ -87,6 +87,12 @@ class MassBuild < ActiveRecord::Base
end
later :publish_test_failed_builds, queue: :clone_build
COUNT_STATUSES.each do |stat|
define_method "#{stat}_count" do
build_lists.where(status: BuildList::HUMAN_STATUSES.key(stat)).count
end if stat != :build_lists
end
private
def generate_list(status)

View File

@ -19,11 +19,11 @@
%td.min_width_120
- MassBuild::COUNT_STATUSES.each do |status|
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(filter: {mass_build_id: mass_build.id, ownership: 'everything'}.merge(status != :build_lists ? {status: BuildList.status_by_human(status)} : {}))
= mass_build.read_attribute "#{status}_count"
= mass_build.send "#{status}_count"
.both
-if mass_build.projects_list.present?
=link_to_list @platform, mass_build, 'missed_projects_list'
= mass_build.read_attribute 'missed_projects_count'
= mass_build.send 'missed_projects_count'
%td
- if mass_build.projects_list.present?
= link_to_list @platform, mass_build, 'projects_list'

View File

@ -0,0 +1,5 @@
class AddMassBuildIndexToBuildList < ActiveRecord::Migration
def change
add_index :build_lists, [:mass_build_id, :status]
end
end

View File

@ -0,0 +1,21 @@
class RemoveCountersFromMassBuild < ActiveRecord::Migration
def up
remove_columns :mass_builds, :build_published_count,
:build_pending_count,
:build_started_count,
:build_publish_count,
:build_error_count,
:success_count,
:build_canceled_count
end
def down
add_column :mass_builds, :build_published_count, :integer, default: 0
add_column :mass_builds, :build_pending_count, :integer, default: 0
add_column :mass_builds, :build_started_count, :integer, default: 0
add_column :mass_builds, :build_publish_count, :integer, default: 0
add_column :mass_builds, :build_error_count, :integer, default: 0
add_column :mass_builds, :success_count, :integer, default: 0
add_column :mass_builds, :build_canceled_count, :integer, default: 0
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140219191644) do
ActiveRecord::Schema.define(:version => 20140224134012) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -149,6 +149,7 @@ ActiveRecord::Schema.define(:version => 20140219191644) do
add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"
add_index "build_lists", ["arch_id"], :name => "index_build_lists_on_arch_id"
add_index "build_lists", ["project_id", "save_to_repository_id", "build_for_platform_id", "arch_id"], :name => "maintainer_search_index"
add_index "build_lists", ["mass_build_id", "status"], :name => "index_build_lists_on_mass_build_id_and_status"
add_index "build_lists", ["project_id"], :name => "index_build_lists_on_project_id"
create_table "comments", :force => true do |t|
@ -285,18 +286,11 @@ ActiveRecord::Schema.define(:version => 20140219191644) do
t.integer "user_id"
t.boolean "auto_publish", :default => false, :null => false
t.integer "build_lists_count", :default => 0, :null => false
t.integer "build_published_count", :default => 0, :null => false
t.integer "build_pending_count", :default => 0, :null => false
t.integer "build_started_count", :default => 0, :null => false
t.integer "build_publish_count", :default => 0, :null => false
t.integer "build_error_count", :default => 0, :null => false
t.boolean "stop_build", :default => false, :null => false
t.text "projects_list"
t.integer "missed_projects_count", :default => 0, :null => false
t.text "missed_projects_list"
t.boolean "new_core", :default => true
t.integer "success_count", :default => 0, :null => false
t.integer "build_canceled_count", :default => 0, :null => false
t.integer "save_to_platform_id", :null => false
t.text "extra_repositories"
t.text "extra_build_lists"