MS DG fix soup, memoize posts

This commit is contained in:
Maxwell Salzberg 2011-10-14 14:23:18 -07:00
parent 5a8024a71a
commit bde5fd205c

View file

@ -12,31 +12,33 @@ class Stream::Soup < Stream::Base
end end
def posts def posts
@posts ||= lambda do
post_ids = aspect_posts_ids + followed_tag_ids + mentioned_post_ids post_ids = aspect_posts_ids + followed_tag_ids + mentioned_post_ids
post_ids += featured_user_post_ids post_ids += featured_user_post_ids
Post.where(:id => post_ids).for_a_stream(max_time, order) Post.where(:id => post_ids).for_a_stream(max_time, order)
end.call
end end
def ajax_stream? def ajax_stream?
true false
end end
private private
def aspect_posts_ids def aspect_posts_ids
user.visible_post_ids(:limit => 15, :order => order, :max_time => max_time) @aspect_posts_ids ||= user.visible_post_ids(:limit => 15, :order => "#{order} DESC", :max_time => max_time, :all_aspects? => true, :by_members_of => aspect_ids)
end end
def followed_tag_ids def followed_tag_ids
ids(StatusMessage.tag_stream(user, tag_array, max_time, order)) @followed_tag_ids ||= ids(StatusMessage.tag_stream(user, tag_array, max_time, order))
end end
def mentioned_post_ids def mentioned_post_ids
ids(StatusMessage.where_person_is_mentioned(user.person).for_a_stream(max_time, order)) @mentioned_post_ids ||= ids(StatusMessage.where_person_is_mentioned(user.person).for_a_stream(max_time, order))
end end
def featured_user_post_ids def featured_user_post_ids
ids(Post.all_public.where(:author_id => featured_user_ids).for_a_stream(max_time, order)) @featured_user_post_ids ||= ids(Post.all_public.where(:author_id => featured_user_ids).for_a_stream(max_time, order))
end end
#worthless helpers #worthless helpers