Commit 66186a31 authored by Michael Rose's avatar Michael Rose

recommendations: keep stories sorted

parent 7e2ae063
module StoryFetchers
extend ActiveSupport::Concern
def from_story_ids(story_ids)
stories_by_id =
Story.where(id: story_ids)
.includes([:author, :story_to_thread])
.index_by(&:id) { |id| stories_by_id[id] }.compact
def opened_stories(story_ids)
from_search_results do
current_user.story_clicks.where(story_id: story_ids)
......@@ -8,11 +8,7 @@ class User::RecommendationsController < ApplicationController
@opened_stories = opened_stories(top_n)
@read_stories = read_stories(top_n)
@queued_stories = queued_stories(top_n)
@stories = Story.where(id: top_n)
.includes([:author, :story_to_thread])
.reject { |r| r == nil }
@stories = from_story_ids(top_n)
def create
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment