remove old activity feeds
This commit is contained in:
parent
95d262b92f
commit
50ce84bfa9
|
@ -10,6 +10,7 @@ class ActivityFeed < ActiveRecord::Base
|
|||
serialize :data
|
||||
|
||||
default_scope order('created_at DESC')
|
||||
scope :outdated, offset(100)
|
||||
|
||||
self.per_page = 10
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue