From 68b86ba09aa98de4af2a26d6fb502cddc9c55f76 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Thu, 30 Aug 2012 20:19:12 +0400 Subject: [PATCH] [issue #620] Fixed migration && BuildList#actualize_packages. --- .../platforms/maintainers_controller.rb | 3 +- .../projects/projects_controller.rb | 3 +- app/models/build_list.rb | 4 +- app/models/project.rb | 6 +- config/locales/models/maintainer.ru.yml | 14 +-- ...10712_add_actual_to_build_list_packages.rb | 6 +- db/schema.rb | 90 +++++++++---------- 7 files changed, 62 insertions(+), 64 deletions(-) diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 947b575fe..414c37612 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -6,8 +6,7 @@ class Platforms::MaintainersController < ApplicationController def index @maintainers = BuildList::Package.actual.by_platform(@platform) - .order('lower(name) ASC') - .order('length(name) ASC') + .order('lower(name) ASC, length(name) ASC') .includes(:project) @maintainers = @maintainers.find_by_name(params[:q]) if params[:q].present? @maintainers = @maintainers.paginate(:page => params[:page]) diff --git a/app/controllers/projects/projects_controller.rb b/app/controllers/projects/projects_controller.rb index 09a61198b..0720e5e8d 100644 --- a/app/controllers/projects/projects_controller.rb +++ b/app/controllers/projects/projects_controller.rb @@ -88,8 +88,7 @@ class Projects::ProjectsController < Projects::BaseController end def autocomplete_maintainers - term = params[:term] - limit = 10 + term, limit = params[:term], params[:limit] || 10 items = User.member_of_project(@project) .where("users.name ILIKE ? OR users.uname ILIKE ?", "%#{term}%", "%#{term}%") .limit(limit).map { |u| {:value => u.fullname, :label => u.fullname, :id => u.id} } diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 8fe59c356..4c63c0e58 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -208,8 +208,8 @@ class BuildList < ActiveRecord::Base .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) + .recent[-2].try(:packages) # packages from previous build_list + old_pkgs.update_all(:actual => false) if old_pkgs self.packages.update_all(:actual => true) end end diff --git a/app/models/project.rb b/app/models/project.rb index 53e6a81f9..642420088 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -43,10 +43,10 @@ class Project < ActiveRecord::Base scope :addable_to_repository, lambda { |repository_id| where %Q( projects.id NOT IN ( SELECT - project_to_repositories.project_id + ptr.project_id FROM - project_to_repositories - WHERE (project_to_repositories.repository_id = #{ repository_id }) + project_to_repositories AS ptr + WHERE (ptr.repository_id = #{ repository_id }) ) ) } diff --git a/config/locales/models/maintainer.ru.yml b/config/locales/models/maintainer.ru.yml index 71a6bec87..04cd6f7b8 100644 --- a/config/locales/models/maintainer.ru.yml +++ b/config/locales/models/maintainer.ru.yml @@ -1,20 +1,20 @@ ru: layout: maintainers: - list_header: Мэйнтэйнеры + list_header: Майнтейнеры search_by_package: Искать по имени пакета flash: maintainer: - saved: Мэйнтэйнер успешно сохранен - created: Мэйнтэйнер успешно добавлен - save_error: Не удалось сохранить мэйнтэйнера - create_error: Не удалось создать мэйнтэйнера - destroyed: Мэйнтэйнер успешно удален + saved: Майнтейнер успешно сохранен + created: Майнтейнер успешно добавлен + save_error: Не удалось сохранить майнтейнера + create_error: Не удалось создать майнтейнера + destroyed: Майнтейнер успешно удален activerecord: models: - maintainer: Мэйнтэйнер + maintainer: Майнтейнер attributes: maintainer: package_name: Пакет 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 2dfd46749..847eed97e 100644 --- a/db/migrate/20120822210712_add_actual_to_build_list_packages.rb +++ b/db/migrate/20120822210712_add_actual_to_build_list_packages.rb @@ -1,14 +1,14 @@ 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_packages, [:actual, :platform_id] add_index :build_lists, [:project_id, :save_to_repository_id, :build_for_platform_id, :arch_id], :name => :maintainer_search_index end def self.down + remove_index :build_list_packages, [:actual, :platform_id] remove_column :build_list_packages, :actual - remove_index :build_list_packages, [:actual, :platform_id], :name => :actual_platform_packages - remove_index :build_lists, [:project_id, :save_to_repository_id, :build_for_platform_id, :arch_id] + remove_index :build_lists, :name => :maintainer_search_index end end diff --git a/db/schema.rb b/db/schema.rb index 9d12797ec..0e9ea414e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,8 +17,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.integer "user_id", :null => false t.string "kind" t.text "data" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "advisories", :force => true do |t| @@ -53,8 +53,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do create_table "arches", :force => true do |t| t.string "name", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "arches", ["name"], :name => "index_arches_on_name", :unique => true @@ -63,8 +63,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.integer "user_id" t.string "provider" t.string "uid" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "authentications", ["provider", "uid"], :name => "index_authentications_on_provider_and_uid", :unique => true @@ -75,8 +75,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.integer "level" t.integer "status" t.integer "build_list_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "version" end @@ -96,7 +96,7 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.boolean "actual", :default => false end - add_index "build_list_packages", ["actual", "platform_id"], :name => "actual_platform_packages" + add_index "build_list_packages", ["actual", "platform_id"], :name => "index_build_list_packages_on_actual_and_platform_id" add_index "build_list_packages", ["build_list_id"], :name => "index_build_list_packages_on_build_list_id" add_index "build_list_packages", ["name", "project_id"], :name => "index_build_list_packages_on_name_and_project_id" add_index "build_list_packages", ["platform_id"], :name => "index_build_list_packages_on_platform_id" @@ -110,8 +110,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.integer "project_id" t.integer "arch_id" t.datetime "notified_at" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "is_circle", :default => false t.text "additional_repos" t.string "name" @@ -142,8 +142,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "commentable_type" t.integer "user_id" t.text "body" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.decimal "commentable_id", :precision => 50, :scale => 0 t.integer "project_id" end @@ -160,8 +160,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "controller" t.string "action" t.text "message" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "flash_notifies", :force => true do |t| @@ -175,8 +175,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do create_table "groups", :force => true do |t| t.integer "owner_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "uname" t.integer "own_projects_count", :default => 0, :null => false t.text "description" @@ -189,8 +189,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "title" t.text "body" t.string "status", :default => "open" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "user_id" t.datetime "closed_at" t.integer "closed_by" @@ -250,8 +250,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "description" t.string "name", :null => false t.integer "parent_platform_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "released", :default => false, :null => false t.integer "owner_id" t.string "owner_type" @@ -266,16 +266,16 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.integer "platform_id" t.string "login" t.string "password" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "user_id" end create_table "product_build_lists", :force => true do |t| t.integer "product_id" t.integer "status", :default => 2, :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id" @@ -283,8 +283,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do create_table "products", :force => true do |t| t.string "name", :null => false t.integer "platform_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "build_script" t.text "counter" t.text "ks" @@ -303,8 +303,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "name" t.string "version" t.datetime "file_mtime" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "platform_id" end @@ -313,14 +313,14 @@ ActiveRecord::Schema.define(:version => 20120822210712) do create_table "project_to_repositories", :force => true do |t| t.integer "project_id" t.integer "repository_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "projects", :force => true do |t| t.string "name" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.integer "owner_id" t.string "owner_type" t.string "visibility", :default => "open" @@ -347,8 +347,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do 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 @@ -361,16 +361,16 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "actor_type" t.integer "target_id" t.string "target_type" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "role" end create_table "repositories", :force => true do |t| t.string "description", :null => false t.integer "platform_id", :null => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "name", :null => false end @@ -381,8 +381,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.boolean "new_comment_reply", :default => true t.boolean "new_issue", :default => true t.boolean "issue_assign", :default => true - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "new_comment_commit_owner", :default => true t.boolean "new_comment_commit_repo_owner", :default => true t.boolean "new_comment_commit_commentor", :default => true @@ -391,8 +391,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do create_table "subscribes", :force => true do |t| t.string "subscribeable_type" t.integer "user_id" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.boolean "status", :default => true t.integer "project_id" t.decimal "subscribeable_id", :precision => 50, :scale => 0 @@ -405,8 +405,8 @@ ActiveRecord::Schema.define(:version => 20120822210712) do t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "ssh_key" t.string "uname" t.string "role"