个人首页的留言动态显示不合理

This commit is contained in:
cxt 2015-11-09 16:08:15 +08:00
parent dc7a90cab5
commit 2a82f33227
5 changed files with 82 additions and 30 deletions

View File

@ -60,6 +60,11 @@ class WordsController < ApplicationController
course_activity.updated_at = Time.now
course_activity.save
end
principal_activity = PrincipalActivity.where("principal_act_type='JournalsForMessage' and principal_act_id =#{parent_id}").first
if principal_activity
principal_activity.updated_at = Time.now
principal_activity.save
end
user_activity = UserActivity.where("act_type='JournalsForMessage' and act_id =#{parent_id}").first
if user_activity
user_activity.updated_at = Time.now

View File

@ -136,10 +136,8 @@ class JournalsForMessage < ActiveRecord::Base
#用户动态公共表记录
def act_as_principal_activity
if self.jour_type == 'Principal'
unless self.user_id == self.jour.id && self.user_id != self.reply_id && self.reply_id != 0
self.principal_acts << PrincipalActivity.new(:user_id => self.user_id, :principal_id => self.jour_id)
end
if self.jour_type == 'Principal' && self.m_parent_id.nil?
self.principal_acts << PrincipalActivity.new(:user_id => self.user_id, :principal_id => self.jour_id)
end
end

View File

@ -0,0 +1,40 @@
class DeleteJournalsActivity < ActiveRecord::Migration
def up
UserActivity.all.each do |activity|
if activity.act_type == 'JournalsForMessage'
if activity.act
unless activity.act.m_parent_id.nil?
parent_act = UserActivity.where("act_id = #{activity.act.m_parent_id} and act_type='JournalsForMessage' and container_type='Principal'").first
if parent_act
parent_act.created_at = activity.act.parent.children.maximum("created_on")
parent_act.save
activity.destroy
end
end
else
activity.destroy
end
end
end
PrincipalActivity.all.each do |activity|
if activity.principal_act_type == 'JournalsForMessage'
if activity.principal_act
unless activity.principal_act.m_parent_id.nil?
parent_act = PrincipalActivity.where("principal_act_id = #{activity.principal_act.m_parent_id} and principal_act_type='JournalsForMessage'").first
if parent_act
parent_act.created_at = activity.principal_act.parent.children.maximum("created_on")
parent_act.save
activity.destroy
end
end
else
activity.destroy
end
end
end
end
def down
end
end

View File

@ -0,0 +1,16 @@
class AlterUserActivitiesUpdate < ActiveRecord::Migration
def up
count = UserActivity.all.count / 30 + 2
transaction do
for i in 1 ... count do i
UserActivity.page(i).per(30).each do |activity|
activity.updated_at = activity.created_at
activity.save
end
end
end
end
def down
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20151102090519) do
ActiveRecord::Schema.define(:version => 20151109080256) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -528,23 +528,26 @@ ActiveRecord::Schema.define(:version => 20151102090519) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :force => true do |t|
t.string "IPLineCode"
t.string "Description"
t.string "Num"
t.string "Variable"
t.string "TraceInfo"
t.string "Method"
create_table "dts", :primary_key => "Num", :force => true do |t|
t.string "Defect", :limit => 50
t.string "Category", :limit => 50
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
t.string "Description"
t.text "PreConditions", :limit => 2147483647
t.text "TraceInfo", :limit => 2147483647
t.text "Code", :limit => 2147483647
t.integer "project_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "id", :null => false
end
create_table "enabled_modules", :force => true do |t|
@ -814,16 +817,6 @@ ActiveRecord::Schema.define(:version => 20151102090519) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id"
t.integer "user_id"