From 2c49b34ebf938e0e0a3d146f2e1fa5c6a0b244e4 Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Tue, 31 Mar 2020 09:04:20 -0500 Subject: [PATCH] Hotness Score for Tags Should Use Article positive_reactions_count (#6808) [deploy] Co-authored-by: Ben Halpern --- app/models/tag.rb | 2 +- .../20200324133751_update_tag_hotness_scores.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/data_update_scripts/20200324133751_update_tag_hotness_scores.rb diff --git a/app/models/tag.rb b/app/models/tag.rb index c86969c89..c6fcc25b0 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -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 diff --git a/lib/data_update_scripts/20200324133751_update_tag_hotness_scores.rb b/lib/data_update_scripts/20200324133751_update_tag_hotness_scores.rb new file mode 100644 index 000000000..e4ce5bdcd --- /dev/null +++ b/lib/data_update_scripts/20200324133751_update_tag_hotness_scores.rb @@ -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