This commit is contained in:
Toks
2013-12-09 15:05:12 -05:00
parent 74e30ea25b
commit 347561c838
3 changed files with 9 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ class PostVersionsController < ApplicationController
rescue_from ActiveRecord::StatementInvalid, :with => :rescue_exception
def index
@post_versions = PostVersion.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
@post_versions = PostVersion.search(params[:search]).order("updated_at desc, id desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
respond_with(@post_versions) do |format|
format.xml do
render :xml => @post_versions.to_xml(:root => "post-versions")

View File

@@ -26,7 +26,7 @@ class Post < ActiveRecord::Base
has_one :artist_commentary
has_many :flags, :class_name => "PostFlag", :dependent => :destroy
has_many :appeals, :class_name => "PostAppeal", :dependent => :destroy
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.id ASC"
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.updated_at ASC, post_versions.id ASC"
has_many :votes, :class_name => "PostVote", :dependent => :destroy
has_many :notes, :dependent => :destroy
has_many :comments, :order => "comments.id", :dependent => :destroy

View File

@@ -65,7 +65,7 @@ class PostVersion < ActiveRecord::Base
end
def sequence_for_post
versions = PostVersion.where(:post_id => post_id).order("updated_at desc").all
versions = PostVersion.where(:post_id => post_id).order("updated_at desc, id desc").all
diffs = []
versions.each_index do |i|
if i < versions.size - 1
@@ -130,7 +130,12 @@ class PostVersion < ActiveRecord::Base
end
def previous
PostVersion.where("post_id = ? and updated_at < ?", post_id, updated_at).order("updated_at desc").first
if updated_at.to_i == Time.zone.parse("2007-03-14T19:38:12Z").to_i
# Old post versions which didn't have updated_at set correctly
PostVersion.where("post_id = ? and updated_at = ? and id < ?", post_id, updated_at, id).order("updated_at desc, id desc").first
else
PostVersion.where("post_id = ? and updated_at < ?", post_id, updated_at).order("updated_at desc, id desc").first
end
end
def truncated_source