[refs #762] refactoring

This commit is contained in:
Alexander Machehin 2012-12-11 19:48:16 +06:00
parent 80921e4237
commit a452df79b8
7 changed files with 35 additions and 27 deletions

View File

@ -112,29 +112,27 @@ class Platforms::RepositoriesController < Platforms::BaseController
sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc' sort_dir = params[:sSortDir_0]=="asc" ? 'asc' : 'desc'
order = "#{colName[sort_col.to_i]} #{sort_dir}" order = "#{colName[sort_col.to_i]} #{sort_dir}"
if params[:text] == 'true' render(:text => @repository.projects.map(&:name).join("\n")) && return if params[:text] == 'true'
render :text => @repository.projects.map(&:name).join("\n")
if params[:added] == "true"
@projects = @repository.projects
else else
if params[:added] == "true" @projects = Project.joins(owner_subquery).addable_to_repository(@repository.id)
@projects = @repository.projects @projects = @projects.by_visibilities('open') if @repository.platform.platform_type == 'main'
else end
@projects = Project.joins(owner_subquery).addable_to_repository(@repository.id) @projects = @projects.paginate(
@projects = @projects.by_visibilities('open') if @repository.platform.platform_type == 'main' :page => (params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1,
end :per_page => params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
@projects = @projects.paginate( )
:page => (params[:iDisplayStart].to_i/(params[:iDisplayLength].present? ? params[:iDisplayLength] : 25).to_i).to_i + 1,
:per_page => params[:iDisplayLength].present? ? params[:iDisplayLength] : 25
)
@total_projects = @projects.count @total_projects = @projects.count
@projects = @projects.search(params[:sSearch]).search_order if params[:sSearch].present? @projects = @projects.search(params[:sSearch]).search_order if params[:sSearch].present?
@projects = @projects.order(order) @projects = @projects.order(order)
respond_to do |format| respond_to do |format|
format.json { format.json {
render :partial => (params[:added] == "true") ? 'project' : 'proj_ajax', :layout => false render :partial => (params[:added] == "true") ? 'project' : 'proj_ajax', :layout => false
} }
end
end end
end end

View File

@ -24,7 +24,6 @@ class MassBuild < ActiveRecord::Base
:build_error :build_error
] ]
# ATTENTION: repositories and arches must be set before calling this method!
def build_all def build_all
# later with resque # later with resque
arches_list = arches ? Arch.where(:id => arches) : Arch.all arches_list = arches ? Arch.where(:id => arches) : Arch.all
@ -34,8 +33,7 @@ class MassBuild < ActiveRecord::Base
next if name.blank? next if name.blank?
name.chomp!; name.strip! name.chomp!; name.strip!
if project = Project.joins(:repositories).where(:name => name) if project = Project.joins(:repositories).where('repositories.id in (?)', platform.repository_ids).find_by_name(name)
.where('repositories.id in (?)', platform.repository_ids).first
begin begin
return if self.reload.stop_build return if self.reload.stop_build
arches_list.each do |arch| arches_list.each do |arch|

View File

@ -22,4 +22,3 @@ en:
user: User user: User
auto_publish: Auto Publish auto_publish: Auto Publish
repositories: Repositories repositories: Repositories
rep_names: Repositories

View File

@ -22,4 +22,3 @@ ru:
user: Пользователь user: Пользователь
auto_publish: Авто Публикация auto_publish: Авто Публикация
repositories: Репозитории repositories: Репозитории
rep_names: Репозитории

View File

@ -0,0 +1,5 @@
class RemoveRepNamesFromMassBuild < ActiveRecord::Migration
def change
remove_column :mass_builds, :rep_names
end
end

View File

@ -0,0 +1,6 @@
class AddIndexes < ActiveRecord::Migration
def change
add_index :project_to_repositories, [:repository_id, :project_id], :unique => true
add_index :repositories, :platform_id
end
end

View File

@ -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 => 20121206143724) do ActiveRecord::Schema.define(:version => 20121211132948) 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
@ -250,7 +250,6 @@ ActiveRecord::Schema.define(:version => 20121206143724) do
t.integer "build_started_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_publish_count", :default => 0, :null => false
t.integer "build_error_count", :default => 0, :null => false t.integer "build_error_count", :default => 0, :null => false
t.string "rep_names"
t.boolean "stop_build", :default => false, :null => false t.boolean "stop_build", :default => false, :null => false
t.text "projects_list" t.text "projects_list"
t.integer "missed_projects_count", :default => 0, :null => false t.integer "missed_projects_count", :default => 0, :null => false
@ -330,6 +329,8 @@ ActiveRecord::Schema.define(:version => 20121206143724) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
add_index "project_to_repositories", ["repository_id", "project_id"], :name => "index_project_to_repositories_on_repository_id_and_project_id", :unique => true
create_table "projects", :force => true do |t| create_table "projects", :force => true do |t|
t.string "name" t.string "name"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
@ -403,6 +404,8 @@ ActiveRecord::Schema.define(:version => 20121206143724) do
t.boolean "publish_without_qa", :default => true t.boolean "publish_without_qa", :default => true
end end
add_index "repositories", ["platform_id"], :name => "index_repositories_on_platform_id"
create_table "settings_notifiers", :force => true do |t| create_table "settings_notifiers", :force => true do |t|
t.integer "user_id", :null => false t.integer "user_id", :null => false
t.boolean "can_notify", :default => true t.boolean "can_notify", :default => true