diff --git a/app/queries/organizations/suggest_prominent.rb b/app/queries/organizations/suggest_prominent.rb index 0de47a50c..af25b069f 100644 --- a/app/queries/organizations/suggest_prominent.rb +++ b/app/queries/organizations/suggest_prominent.rb @@ -13,8 +13,7 @@ module Organizations def suggest return [] if tags_to_consider.empty? - filtered_articles = Article.cached_tagged_with_any(tags_to_consider).where.not(organization_id: nil) - org_ids = fetch_and_pluck_org_ids(filtered_articles) + org_ids = fetch_and_pluck_org_ids Organization.where(id: org_ids.uniq).order(Arel.sql("RANDOM()")).limit(MAX) end @@ -26,9 +25,9 @@ module Organizations user.decorate.cached_followed_tag_names end - def fetch_and_pluck_org_ids(filtered_articles) - order = Arel.sql("(hotness_score * (feed_success_score - clickbait_score)) DESC") - filtered_articles.order(order).limit(MAX * 2).pluck(:organization_id) + def fetch_and_pluck_org_ids + Article.published.cached_tagged_with_any(tags_to_consider).where.not(organization_id: nil) + .order("hotness_score DESC").limit(MAX * 2).pluck(:organization_id) end end end