diff --git a/app/helpers/rb_common_helper.rb b/app/helpers/rb_common_helper.rb index 082543eb0d..998a7a74a3 100644 --- a/app/helpers/rb_common_helper.rb +++ b/app/helpers/rb_common_helper.rb @@ -217,7 +217,7 @@ module RbCommonHelper end def all_work_package_status - @all_work_package_status ||= Status.all(order: 'position ASC') + @all_work_package_status ||= Status.order('position ASC') end def backlogs_types diff --git a/app/models/story.rb b/app/models/story.rb index 89f851ada6..80d6f0c4f0 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -40,7 +40,7 @@ class Story < WorkPackage options.reverse_merge!(order: Story::ORDER, conditions: Story.condition(project_id, sprint_ids)) - candidates = Story.all(options) + candidates = Story.where(options[:conditions]).order(options[:order]) stories_by_version = Hash.new do |hash, sprint_id| hash[sprint_id] = [] diff --git a/app/models/task.rb b/app/models/task.rb index 2c637b7114..55e822900c 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -99,7 +99,7 @@ class Task < WorkPackage end def rank - @rank ||= WorkPackage.count(conditions: ['type_id = ? and not parent_id is NULL and root_id = ? and lft <= ?', Task.type, story_id, lft]) + @rank ||= WorkPackage.where(['type_id = ? and not parent_id is NULL and root_id = ? and lft <= ?', Task.type, story_id, lft]).count @rank end end diff --git a/lib/open_project/backlogs/patches/work_package_patch.rb b/lib/open_project/backlogs/patches/work_package_patch.rb index 1f357bf400..424c02cafa 100644 --- a/lib/open_project/backlogs/patches/work_package_patch.rb +++ b/lib/open_project/backlogs/patches/work_package_patch.rb @@ -212,7 +212,7 @@ module OpenProject::Backlogs::Patches::WorkPackagePatch real_parent = WorkPackage.find_by_id(parent_id) # Sort immediate ancestors first - ancestors = ([real_parent] + real_parent.ancestors.all(include: { project: :enabled_modules })).sort_by(&:right) + ancestors = [real_parent] + real_parent.ancestors.includes(project: :enabled_modules).order(:rgt) end ancestors end