Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
58435c82
Commit
58435c82
authored
Jan 31, 2012
by
Holger Just
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[#775] Remove noisy journals on Attachments and Messages
parent
01fefe8d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
20120131142400_remove_noisy_attachment_journals.rb
...igrate/20120131142400_remove_noisy_attachment_journals.rb
+30
-0
20120131142401_remove_noisy_message_journals.rb
db/migrate/20120131142401_remove_noisy_message_journals.rb
+32
-0
No files found.
db/migrate/20120131142400_remove_noisy_attachment_journals.rb
0 → 100644
View file @
58435c82
#-- 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
db/migrate/20120131142401_remove_noisy_message_journals.rb
0 → 100644
View file @
58435c82
#-- 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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment