remove old activity feeds

This commit is contained in:
Alexander Machehin 2012-11-15 00:10:03 +06:00
parent 95d262b92f
commit 50ce84bfa9
3 changed files with 17 additions and 0 deletions

View File

@ -10,6 +10,7 @@ class ActivityFeed < ActiveRecord::Base
serialize :data
default_scope order('created_at DESC')
scope :outdated, offset(100)
self.per_page = 10

View File

@ -18,3 +18,7 @@ end
every 1.day, :at => '3:30 am' do
rake "pull_requests:clear", :output => 'log/pull_requests_clear.log'
end
every 1.day, :at => '3:00 am' do
rake "activity_feeds:clear", :output => 'log/activity_feeds.log'
end

View File

@ -0,0 +1,12 @@
namespace :activity_feeds do
desc 'Remove outdated activity feeds'
task :clear => :environment do
say "Removing outdated Activity Feed"
User.all.each do |user|
outdated = ActivityFeed.outdated
say "User #{user.uname} has #{outdated.count} outdated ActivityFeed."
user.activity_feeds.outdated.destroy_all if outdated.count > 0
end
say "Outdated activity feeds was successfully removed."
end
end