]> cat aescling's git repositories - mastodon.git/commitdiff
Do not raise an error if PrecomputeFeed could not find any status (#4015)
authorAkihiko Odaki (@fn_aki@pawoo.net) <akihiko.odaki.4i@stu.hosei.ac.jp>
Fri, 30 Jun 2017 11:39:42 +0000 (20:39 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Fri, 30 Jun 2017 11:39:42 +0000 (13:39 +0200)
app/services/precompute_feed_service.rb
spec/services/precompute_feed_service_spec.rb

index e2f6ff0cb8467db46aff08a36af4d28a58d8f238..a32ba1dae4f15b00c01ff0e9241b36b3bb99c158 100644 (file)
@@ -16,7 +16,7 @@ class PrecomputeFeedService < BaseService
     pairs = statuses.reverse_each.map(&method(:process_status))
 
     redis.pipelined do
-      redis.zadd(account_home_key, pairs)
+      redis.zadd(account_home_key, pairs) if pairs.any?
       redis.del("account:#{@account.id}:regeneration")
     end
   end
index 72235a9664faf5f6bf4e69b88df2b01eeeba68ac..e2294469c0376fac1b23197fdf979b1a86550c64 100644 (file)
@@ -18,5 +18,10 @@ RSpec.describe PrecomputeFeedService do
 
       expect(Redis.current.zscore(FeedManager.instance.key(:home, account.id), reblog.id)).to eq status.id
     end
+
+    it 'does not raise an error even if it could not find any status' do
+      account = Fabricate(:account)
+      subject.call(account)
+    end
   end
 end