From 6297acbd5bc1bc1420eba3fb7d1b1d56b4605bec Mon Sep 17 00:00:00 2001 From: Josh Puetz Date: Fri, 19 Aug 2022 11:06:13 -0400 Subject: [PATCH] Added relevancy lever based on comments scores of an article (#18352) --- app/models/articles/feeds.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/models/articles/feeds.rb b/app/models/articles/feeds.rb index bb6cc793c..722b2439f 100644 --- a/app/models/articles/feeds.rb +++ b/app/models/articles/feeds.rb @@ -139,6 +139,20 @@ module Articles select_fragment: "articles.comments_count", group_by_fragment: "articles.comments_count") + relevancy_lever(:comments_score, + label: "Weight given based on sum of comment scores of an article.", + range: "[0..∞)", + user_required: false, + select_fragment: "SUM( + CASE + WHEN comments.score is null then 0 + ELSE comments.score + END)", + joins_fragments: ["LEFT OUTER JOIN comments + ON comments.commentable_id = articles.id + AND comments.commentable_type = 'Article' + AND comments.deleted = false"]) + relevancy_lever(:daily_decay, label: "Weight given based on the relative age of the article", range: "[0..∞)", @@ -311,6 +325,7 @@ module Articles very_positive_reaction_threshold positive_reaction_threshold ]) + relevancy_lever(:public_reactions, label: "Weight to give for the number of unicorn, heart, reading list reactions for article.", range: "[0..∞)",