stories should have a well-defined order on all DBs

NULL should be in front (COALESCE)
and if the issues have the same id, the older one should win
pull/6827/head
Gregor Schmidt 13 years ago
parent 95ef4d50aa
commit 5c846ca548
  1. 2
      lib/backlogs/patches/version_patch.rb

@ -24,7 +24,7 @@ module Backlogs::Patches::VersionPatch
# and add issues, that have a position, at the end
stories_wo_position = self.fixed_issues.find(:all, :conditions => {:project_id => project, :tracker_id => Story.trackers, :position => nil}, :order => 'id')
stories_w_position = self.fixed_issues.find(:all, :conditions => ['project_id = ? AND tracker_id IN (?) AND position IS NOT NULL', project, Story.trackers], :order => 'position')
stories_w_position = self.fixed_issues.find(:all, :conditions => ['project_id = ? AND tracker_id IN (?) AND position IS NOT NULL', project, Story.trackers], :order => 'COALESCE(position, 0), id')
(stories_w_position + stories_wo_position).each_with_index do |story, index|
story.send(:update_attribute_silently, 'position', index + 1)

Loading…
Cancel
Save