From 7362469d8956d5f972283aadd4157631aa66b085 Mon Sep 17 00:00:00 2001 From: "Akihiko Odaki (@fn_aki@pawoo.net)" Date: Fri, 30 Jun 2017 20:39:42 +0900 Subject: [PATCH] Do not raise an error if PrecomputeFeed could not find any status (#4015) --- app/services/precompute_feed_service.rb | 2 +- spec/services/precompute_feed_service_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/services/precompute_feed_service.rb b/app/services/precompute_feed_service.rb index e2f6ff0cb8..a32ba1dae4 100644 --- a/app/services/precompute_feed_service.rb +++ b/app/services/precompute_feed_service.rb @@ -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 diff --git a/spec/services/precompute_feed_service_spec.rb b/spec/services/precompute_feed_service_spec.rb index 72235a9664..e2294469c0 100644 --- a/spec/services/precompute_feed_service_spec.rb +++ b/spec/services/precompute_feed_service_spec.rb @@ -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