]> cat aescling's git repositories - mastodon.git/commitdiff
Only distribute statuses to followers who signed in in the last 2 weeks, add rake...
authorEugen Rochko <eugen@zeonfederated.com>
Thu, 24 Nov 2016 17:17:58 +0000 (18:17 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Thu, 24 Nov 2016 17:17:58 +0000 (18:17 +0100)
app/services/fan_out_on_write_service.rb
config/environments/production.rb
lib/tasks/mastodon.rake

index 78cb0b13f8cebf0db4b57de3be8002a8505b0f13..78301c6ca97ae46fd1c79914837fbf2f29c39a71 100644 (file)
@@ -24,7 +24,7 @@ class FanOutOnWriteService < BaseService
   def deliver_to_followers(status)
     Rails.logger.debug "Delivering status #{status.id} to followers"
 
-    status.account.followers.where(domain: nil).find_each do |follower|
+    status.account.followers.where(domain: nil).joins(:user).where('users.current_sign_in_at > ?', 14.days.ago).find_each do |follower|
       next if FeedManager.instance.filter?(:home, status, follower)
       FeedManager.instance.push(:home, follower, status)
     end
index 7f13fcf6b3299e6a5b55c2aefb1f3fbb5616d886..dcb659d6cc91dc65d1c8a52bfa8a706980868b61 100644 (file)
@@ -50,7 +50,8 @@ Rails.application.configure do
     host: ENV.fetch('REDIS_HOST') { 'localhost' },
     port: ENV.fetch('REDIS_PORT') { 6379 },
     db: 0,
-    namespace: 'cache'
+    namespace: 'cache',
+    expires_in: 20.minutes
   }
 
   # Enable serving of images, stylesheets, and JavaScripts from an asset server.
index 58bafff662ccb7e5a67675b67c950b074e09feb6..93461bd0af3793e9c77f461789b031200b1cc37b 100644 (file)
@@ -36,8 +36,16 @@ namespace :mastodon do
   end
 
   namespace :feeds do
-    desc 'Clears all timelines so that they would be regenerated on next hit'
+    desc 'Clear timelines of inactive users'
     task clear: :environment do
+      User.where('current_sign_in_at < ?', 14.days.ago).find_each do |user|
+        Redis.current.del(FeedManager.instance.key(:home, user.account_id))
+        Redis.current.del(FeedManager.instance.key(:mentions, user.account_id))
+      end
+    end
+
+    desc 'Clears all timelines so that they would be regenerated on next hit'
+    task clear_all: :environment do
       Redis.current.keys('feed:*').each { |key| Redis.current.del(key) }
     end
   end