Browse Source

Fix code style of regeneration-related code (#9843)

Eugen Rochko 5 years ago
parent
commit
69f782b54d
2 changed files with 3 additions and 1 deletions
  1. 2 1
      app/models/user.rb
  2. 1 0
      app/services/precompute_feed_service.rb

+ 2 - 1
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
 

+ 1 - 0
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