[deploy] Optimization:Limit Tags Searched For Follow Suggestions (#11095)

This commit is contained in:
Molly Struve 2020-10-27 12:58:54 -04:00 committed by GitHub
parent c91c07920f
commit 9af35bed0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,7 @@ module Suggester
def tagged_article_user_ids(num_weeks = 1)
Article.published
.tagged_with(user.decorate.cached_followed_tag_names, any: true)
.tagged_with(user.decorate.cached_followed_tag_names.sample(5), any: true)
.where("score > ? AND published_at > ?", article_reaction_count, num_weeks.weeks.ago)
.pluck(:user_id)
.each_with_object(Hash.new(0)) { |value, counts| counts[value] += 1 }