Commit 59b7885cb32a532601bc4c4d5c19737f94bd1d09
1 parent
6843d0e0
Exists in
master
and in
29 other branches
Added migration and schema
Showing
1 changed file
with
8 additions
and
2 deletions
Show diff stats
db/migrate/20111228202739_remove_useless_tracked_actions.rb
1 | class RemoveUselessTrackedActions < ActiveRecord::Migration | 1 | class RemoveUselessTrackedActions < ActiveRecord::Migration |
2 | def self.up | 2 | def self.up |
3 | - select_all("SELECT id FROM action_tracker WHERE verb IN ('update_article', 'remove_article', 'leave_comment', 'leave_community', 'remove_member_in_community')").each do |tracker| | 3 | + select_all("SELECT id FROM action_tracker").each do |tracker| |
4 | + verbs = ['update_article', 'remove_article', 'leave_comment', 'leave_community', 'remove_member_in_community'] | ||
4 | activity = ActionTracker::Record.find_by_id(tracker['id']) | 5 | activity = ActionTracker::Record.find_by_id(tracker['id']) |
5 | - activity.destroy if activity | 6 | + if activity |
7 | + if (activity.updated_at.to_time < Time.now.months_ago(3)) || verbs.include?(activity.verb) | ||
8 | + activity.destroy | ||
9 | + end | ||
10 | + # select_all("SELECT id, verb, updated_at FROM action_tracker WHERE verb IN ('create_article', 'update_article', 'remove_article', 'leave_comment', 'leave_community', 'remove_member_in_community')").each do |tracker| | ||
11 | + end | ||
6 | end | 12 | end |
7 | end | 13 | end |
8 | 14 |