fixes #1361
This commit is contained in:
@@ -26,9 +26,9 @@ class Post < ActiveRecord::Base
|
||||
has_many :versions, :class_name => "PostVersion", :dependent => :destroy, :order => "post_versions.id ASC"
|
||||
has_many :votes, :class_name => "PostVote", :dependent => :destroy
|
||||
has_many :notes, :dependent => :destroy
|
||||
has_many :comments, :order => "comments.id"
|
||||
has_many :comments, :order => "comments.id", :dependent => :destroy
|
||||
has_many :children, :class_name => "Post", :foreign_key => "parent_id", :order => "posts.id"
|
||||
has_many :disapprovals, :class_name => "PostDisapproval"
|
||||
has_many :disapprovals, :class_name => "PostDisapproval", :dependent => :destroy
|
||||
validates_uniqueness_of :md5
|
||||
validates_presence_of :parent, :if => lambda {|rec| !rec.parent_id.nil?}
|
||||
attr_accessible :source, :rating, :tag_string, :old_tag_string, :last_noted_at, :parent_id, :as => [:member, :builder, :privileged, :platinum, :contributor, :janitor, :moderator, :admin, :default]
|
||||
|
||||
@@ -5,5 +5,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config',
|
||||
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||
|
||||
Post.select("id, score, up_score, down_score, fav_count").find_each do |post|
|
||||
post.update_column(:score, post.up_score - post.down_score + post.fav_count)
|
||||
post.update_column(:score, post.up_score + post.down_score + post.fav_count)
|
||||
end
|
||||
|
||||
Comment.find_each do |comment|
|
||||
if !Post.exists?("id = #{comment.post_id}")
|
||||
comment.destroy
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user