diff --git a/app/decorators/user_decorator.rb b/app/decorators/user_decorator.rb index eedbb50b2..07a78fb39 100644 --- a/app/decorators/user_decorator.rb +++ b/app/decorators/user_decorator.rb @@ -19,16 +19,15 @@ class UserDecorator < ApplicationDecorator ].freeze def cached_followed_tags - Rails.cache.fetch("user-#{id}-#{updated_at}/followed_tags_11-30", expires_in: 20.hours) do - follows = Follow.follower_tag(id).pluck(:followable_id, :points) - follows_map = follows.to_h - - tags = Tag.where(id: follows_map.keys).order(hotness_score: :desc) - tags.each do |tag| - tag.points = follows_map[tag.id] - end - tags + follows_map = Rails.cache.fetch("user-#{id}-#{last_followed_at&.rfc3339}/followed_tags", expires_in: 20.hours) do + Follow.follower_tag(id).pluck(:followable_id, :points).to_h end + + tags = Tag.where(id: follows_map.keys).order(hotness_score: :desc) + tags.each do |tag| + tag.points = follows_map[tag.id] + end + tags end def darker_color(adjustment = 0.88)