Apply efficiency adjustment to orgs as well (#20710)

This commit is contained in:
Ben Halpern 2024-02-29 18:27:47 -05:00 committed by GitHub
parent 2ad8b7a809
commit c901eb48be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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