sort-changesets-by-id.diff

Yuya Nishihara, 2010-04-20 16:40

Download (2.43 KB)

View differences:

app/models/issue.rb
27 27

  
28 28
  has_many :journals, :as => :journalized, :dependent => :destroy
29 29
  has_many :time_entries, :dependent => :delete_all
30
  has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.committed_on ASC, #{Changeset.table_name}.id ASC"
30
  has_and_belongs_to_many :changesets, :order => "#{Changeset.table_name}.id ASC"
31 31
  
32 32
  has_many :relations_from, :class_name => 'IssueRelation', :foreign_key => 'issue_from_id', :dependent => :delete_all
33 33
  has_many :relations_to, :class_name => 'IssueRelation', :foreign_key => 'issue_to_id', :dependent => :delete_all
app/models/repository.rb
17 17

  
18 18
class Repository < ActiveRecord::Base
19 19
  belongs_to :project
20
  has_many :changesets, :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC"
20
  has_many :changesets, :order => "#{Changeset.table_name}.id DESC"
21 21
  has_many :changes, :through => :changesets
22 22
  
23 23
  # Raw SQL to delete changesets and changes in the database
......
106 106
  def latest_changesets(path, rev, limit=10)
107 107
    if path.blank?
108 108
      changesets.find(:all, :include => :user,
109
                            :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
110 109
                            :limit => limit)
111 110
    else
112 111
      changes.find(:all, :include => {:changeset => :user}, 
113 112
                         :conditions => ["path = ?", path.with_leading_slash],
114
                         :order => "#{Changeset.table_name}.committed_on DESC, #{Changeset.table_name}.id DESC",
113
                         :order => "#{Changeset.table_name}.id DESC",
115 114
                         :limit => limit).collect(&:changeset)
116 115
    end
117 116
  end