From 69f782b54d035789a6386ed979940dd9719af1a1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 18 Jan 2019 01:02:51 +0100 Subject: [PATCH] Fix code style of regeneration-related code (#9843) --- app/models/user.rb | 3 ++- app/services/precompute_feed_service.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 8b374c1825..5aa5c2b15c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -362,7 +362,8 @@ class User < ApplicationRecord end def regenerate_feed! - Redis.current.setnx("account:#{account_id}:regeneration", true) && Redis.current.expire("account:#{account_id}:regeneration", 1.day.seconds) + return unless Redis.current.setnx("account:#{account_id}:regeneration", true) + Redis.current.expire("account:#{account_id}:regeneration", 1.day.seconds) RegenerationWorker.perform_async(account_id) end diff --git a/app/services/precompute_feed_service.rb b/app/services/precompute_feed_service.rb index 4f771ff723..076dedacab 100644 --- a/app/services/precompute_feed_service.rb +++ b/app/services/precompute_feed_service.rb @@ -3,6 +3,7 @@ class PrecomputeFeedService < BaseService def call(account) FeedManager.instance.populate_feed(account) + ensure Redis.current.del("account:#{account.id}:regeneration") end end