Commit 58435c82 authored by Holger Just's avatar Holger Just

[#775] Remove noisy journals on Attachments and Messages

parent 01fefe8d
#-- encoding: UTF-8
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2012 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class RemoveNoisyAttachmentJournals < ActiveRecord::Migration
def self.up
AttachmentJournal.find_each(:batch_size => 100 ) do |j|
if j.changes.keys == ["downloads"]
j.destroy
elsif j.changes.keys.include? "downloads"
j.changes.delete("downloads")
j.save!
end
end
end
def self.down
# no-op as the downloads counter shouldn't be journaled in the first time
end
end
#-- encoding: UTF-8
#-- copyright
# ChiliProject is a project management system.
#
# Copyright (C) 2010-2012 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
class RemoveNoisyMessageJournals < ActiveRecord::Migration
def self.up
noisy_keys = %w[last_reply_id replies_count]
MessageJournal.find_each(:batch_size => 100 ) do |j|
if (j.changes.keys | noisy_keys).sort == noisy_keys
j.destroy
elsif (j.changes.keys & noisy_keys).count > 0
noisy_keys.each{ |k| j.changes.delete(k) }
j.save!
end
end
end
def self.down
# no-op as the pointers shouldn't be journaled in the first time
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment