Fix feed issue which caused wrong posts to show up sometimes (#827)

This commit is contained in:
Ben Halpern 2018-10-04 19:07:36 -04:00 committed by GitHub
parent 9c840030f1
commit 95dacf67fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -5,10 +5,11 @@ class BlackBox
super_super_recent_bonus = article.published_at > 1.hours.ago ? 18 : 0
super_recent_bonus = article.published_at > 3.hours.ago ? 11 : 0
recency_bonus = article.published_at > 11.hours.ago ? 70 : 0
today_bonus = article.published_at > 26.hours.ago ? 280 : 0
today_bonus = article.published_at > 26.hours.ago ? 285 : 0
two_day_bonus = article.published_at > 48.hours.ago ? 120 : 0
FunctionCaller.new("blackbox-production-articleHotness",
{ article: article, user: article.user }.to_json).call +
reaction_points + recency_bonus + super_recent_bonus + super_super_recent_bonus + today_bonus
reaction_points + recency_bonus + super_recent_bonus + super_super_recent_bonus + today_bonus + two_day_bonus
end
def self.comment_quality_score(comment)

View file

@ -115,12 +115,13 @@ class StoriesController < ApplicationController
where("reactions_count > ? OR featured = ?", 10, true).
order("hotness_score DESC")
if user_signed_in?
offset = [0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7].sample #random offset, weighted more towards zero
offset = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7].sample #random offset, weighted more towards zero
@stories = @stories.offset(offset)
end
@featured_story = @stories.where.not(main_image: nil).first&.decorate || Article.new
if user_signed_in?
@new_stories = Article.where("published_at > ? AND score > ?", 4.hours.ago, -30).
where(published: true).
includes(:user).
limit(45).
order("published_at DESC").