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