app/services/news_feed.rb
# Add a story to the user's news feed.
Add a story to the user's news feed.
Add a story to the user ' s news feed .
def add!(story)
    add_story = false
    if story.story_type == "comment"
      if story.group_id || @user == story.target || @user.following.include?(story.target)
        add_story = true
      end
    elsif story.story_type != "followed"
      add_story = true
    end
    if add_story
      $redis.with do |conn|
        conn.zadd @feed_key, story.updated_at.to_i, story.id
        conn.zremrangebyrank(@feed_key, 0, -CACHE_SIZE) if rand < 0.2
      end
    end
  end
def add! ( story ) add_story = false if story . story_type == "comment" if story . group_id || @user == story . target || @user . following . include? ( story . target ) add_story = true end elsif story . story_type != "followed" add_story = true end if add_story $redis . with do | conn | conn . zadd @feed_key , story . updated_at . to_i , story . id conn . zremrangebyrank ( @feed_key , 0 , - CACHE_SIZE ) if rand < 0.2 end end end
Add a story to the user's news feed.
Add a story to the user ' s news feed .
story
<not_specific>