Replaces find(:all) calls.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10917 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2012-12-02 20:23:48 +00:00
parent 96fca0b08f
commit 536747b747
29 changed files with 70 additions and 71 deletions
+7 -7
View File
@@ -53,7 +53,7 @@ task :migrate_from_mantis => :environment do
TRACKER_BUG = Tracker.find_by_position(1)
TRACKER_FEATURE = Tracker.find_by_position(2)
roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
roles = Role.where(:builtin => 0).order('position ASC').all
manager_role = roles[0]
developer_role = roles[1]
DEFAULT_ROLE = roles.last
@@ -241,7 +241,7 @@ task :migrate_from_mantis => :environment do
User.delete_all "login <> 'admin'"
users_map = {}
users_migrated = 0
MantisUser.find(:all).each do |user|
MantisUser.all.each do |user|
u = User.new :firstname => encode(user.firstname),
:lastname => encode(user.lastname),
:mail => user.email,
@@ -263,7 +263,7 @@ task :migrate_from_mantis => :environment do
projects_map = {}
versions_map = {}
categories_map = {}
MantisProject.find(:all).each do |project|
MantisProject.all.each do |project|
p = Project.new :name => encode(project.name),
:description => encode(project.description)
p.identifier = project.identifier
@@ -365,7 +365,7 @@ task :migrate_from_mantis => :environment do
# Bug relationships
print "Migrating bug relations"
MantisBugRelationship.find(:all).each do |relation|
MantisBugRelationship.all.each do |relation|
next unless issues_map[relation.source_bug_id] && issues_map[relation.destination_bug_id]
r = IssueRelation.new :relation_type => RELATION_TYPE_MAPPING[relation.relationship_type]
r.issue_from = Issue.find_by_id(issues_map[relation.source_bug_id])
@@ -379,7 +379,7 @@ task :migrate_from_mantis => :environment do
# News
print "Migrating news"
News.destroy_all
MantisNews.find(:all, :conditions => 'project_id > 0').each do |news|
MantisNews.where('project_id > 0').all.each do |news|
next unless projects_map[news.project_id]
n = News.new :project_id => projects_map[news.project_id],
:title => encode(news.headline[0..59]),
@@ -395,7 +395,7 @@ task :migrate_from_mantis => :environment do
# Custom fields
print "Migrating custom fields"
IssueCustomField.destroy_all
MantisCustomField.find(:all).each do |field|
MantisCustomField.all.each do |field|
f = IssueCustomField.new :name => field.name[0..29],
:field_format => CUSTOM_FIELD_TYPE_MAPPING[field.format],
:min_length => field.length_min,
@@ -407,7 +407,7 @@ task :migrate_from_mantis => :environment do
print '.'
STDOUT.flush
# Trackers association
f.trackers = Tracker.find :all
f.trackers = Tracker.all
# Projects association
field.projects.each do |project|
+6 -6
View File
@@ -61,7 +61,7 @@ namespace :redmine do
'patch' =>TRACKER_FEATURE
}
roles = Role.find(:all, :conditions => {:builtin => 0}, :order => 'position ASC')
roles = Role.where(:builtin => 0).order('position ASC').all
manager_role = roles[0]
developer_role = roles[1]
DEFAULT_ROLE = roles.last
@@ -390,7 +390,7 @@ namespace :redmine do
# Components
print "Migrating components"
issues_category_map = {}
TracComponent.find(:all).each do |component|
TracComponent.all.each do |component|
print '.'
STDOUT.flush
c = IssueCategory.new :project => @target_project,
@@ -404,7 +404,7 @@ namespace :redmine do
# Milestones
print "Migrating milestones"
version_map = {}
TracMilestone.find(:all).each do |milestone|
TracMilestone.all.each do |milestone|
print '.'
STDOUT.flush
# First we try to find the wiki page...
@@ -443,7 +443,7 @@ namespace :redmine do
:field_format => 'string')
next if f.new_record?
f.trackers = Tracker.find(:all)
f.trackers = Tracker.all
f.projects << @target_project
custom_field_map[field.name] = f
end
@@ -454,7 +454,7 @@ namespace :redmine do
r = IssueCustomField.new(:name => 'Resolution',
:field_format => 'list',
:is_filter => true) if r.nil?
r.trackers = Tracker.find(:all)
r.trackers = Tracker.all
r.projects << @target_project
r.possible_values = (r.possible_values + %w(fixed invalid wontfix duplicate worksforme)).flatten.compact.uniq
r.save!
@@ -549,7 +549,7 @@ namespace :redmine do
# Wiki
print "Migrating wiki"
if wiki.save
TracWikiPage.find(:all, :order => 'name, version').each do |page|
TracWikiPage.order('name, version').all.each do |page|
# Do not migrate Trac manual wiki pages
next if TRAC_WIKI_PAGES.include?(page.name)
wiki_edit_count += 1