From 7572562cad2567591756b487bee268e8b6ba3ad3 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Sat, 25 Aug 2012 00:27:10 +0400 Subject: [PATCH] [issue #620] Changed packages actualization. --- app/models/build_list.rb | 9 ++++++++- app/models/build_list/package.rb | 11 ----------- ...0120822210712_add_actual_to_build_list_packages.rb | 3 +++ 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index d2cb768dd..8fe59c356 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -203,7 +203,14 @@ class BuildList < ActiveRecord::Base def actualize_packages ActiveRecord::Base.transaction do - self.packages.each(&:actualize) + old_pkgs = self.class.where(:project_id => self.project_id) + .where(:save_to_repository_id => self.save_to_repository_id) + .for_platform(self.build_for_platform_id) + .scoped_to_arch(self.arch_id) + .for_status(BUILD_PUBLISHED) + .recent.first.packages + old_pkgs.update_all(:actual => false) + self.packages.update_all(:actual => true) end end diff --git a/app/models/build_list/package.rb b/app/models/build_list/package.rb index 21a828e4f..795005c0a 100644 --- a/app/models/build_list/package.rb +++ b/app/models/build_list/package.rb @@ -22,15 +22,4 @@ class BuildList::Package < ActiveRecord::Base def assignee project.maintainer end - - def actualize - ActiveRecord::Base.transaction do - old_pkg = self.class.by_platform(self.platform_id).actual - .by_name(self.name).by_package_type(self.package_type) - - old_pkg.update_all(:actual => false) if old_pkg - self.actual = true - self.save - end - end end diff --git a/db/migrate/20120822210712_add_actual_to_build_list_packages.rb b/db/migrate/20120822210712_add_actual_to_build_list_packages.rb index 177160766..aebe3e5cf 100644 --- a/db/migrate/20120822210712_add_actual_to_build_list_packages.rb +++ b/db/migrate/20120822210712_add_actual_to_build_list_packages.rb @@ -2,9 +2,12 @@ class AddActualToBuildListPackages < ActiveRecord::Migration def self.up add_column :build_list_packages, :actual, :boolean, :default => false add_index :build_list_packages, [:actual, :platform_id], :name => :actual_platform_packages + add_index :build_list, [:project_id, :save_to_repository_id, :build_for_platform_id, :arch_id] end def self.down remove_column :build_list_packages, :actual + remove_index :build_list_packages, [:actual, :platform_id], :name => :actual_platform_packages + remove_index :build_list, [:project_id, :save_to_repository_id, :build_for_platform_id, :arch_id] end end