消息列表中的at消息报500

This commit is contained in:
cxt 2016-08-30 17:11:22 +08:00
parent 3d7d8c5795
commit f4632c432f
3 changed files with 22 additions and 5 deletions

View File

@ -521,10 +521,10 @@ class IssuesController < ApplicationController
def delete_journal
@issue = Issue.find(params[:id])
begin
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id]).first
forge_acts.destroy unless forge_acts.nil?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id]).first
at_message.destroy unless at_message.nil?
forge_acts = ForgeMessage.where(:forge_message_type => "Journal", :forge_message_id => params[:journal_id])
forge_acts.destroy_all unless forge_acts.empty?
at_message = AtMessage.where(:at_message_type => "Journal", :at_message_id => params[:journal_id])
at_message.destroy_all unless at_message.empty?
Journal.delete(params[:journal_id])
rescue Exception => e
puts e

View File

@ -0,0 +1,17 @@
class DeleteNullAtMessages < ActiveRecord::Migration
def up
count = AtMessage.all.count / 30 + 2
transaction do
for i in 1 ... count do i
AtMessage.page(i).per(30).each do |am|
if am.at_message.nil?
am.destroy
end
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 => 20160824073554) do
ActiveRecord::Schema.define(:version => 20160830090214) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false