Hotness Score for Tags Should Use Article positive_reactions_count (#6808) [deploy]

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
This commit is contained in:
Molly Struve 2020-03-31 09:04:20 -05:00 committed by GitHub
parent f557c9d474
commit 2c49b34ebf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -91,7 +91,7 @@ class Tag < ActsAsTaggableOn::Tag
self.hotness_score = Article.tagged_with(name).
where("articles.featured_number > ?", 7.days.ago.to_i).
map do |article|
(article.comments_count * 14) + (article.reactions_count * 4) + rand(6) + ((taggings_count + 1) / 2)
(article.comments_count * 14) + article.score + rand(6) + ((taggings_count + 1) / 2)
end.
sum
end

View file

@ -0,0 +1,8 @@
module DataUpdateScripts
class UpdateTagHotnessScores
def run
# Saving a tag will trigger calculate_hotness_score
Tag.find_each(&:save)
end
end
end