diff options
author | danielgrippi <danielgrippi@gmail.com> | 2012-02-14 07:13:29 +0400 |
---|---|---|
committer | danielgrippi <danielgrippi@gmail.com> | 2012-02-14 07:13:43 +0400 |
commit | 32f93a039131b93a9036d20c7e828a36d6962ea8 (patch) | |
tree | 26c12ef739d513421f21d659776c7d1aa238f414 /lib/stream/base.rb | |
parent | b27961b38a0fd4679f330570f0de6df4ac4d9ac5 (diff) |
you can now follow / unfollow a post from the stream; fixed cukes.
Diffstat (limited to 'lib/stream/base.rb')
-rw-r--r-- | lib/stream/base.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/stream/base.rb b/lib/stream/base.rb index b3af708ca..27281581a 100644 --- a/lib/stream/base.rb +++ b/lib/stream/base.rb @@ -40,6 +40,7 @@ class Stream::Base def stream_posts self.posts.for_a_stream(max_time, order, self.user).tap do |posts| like_posts_for_stream!(posts) #some sql person could probably do this with joins. + participation_posts_for_stream!(posts) end end @@ -112,6 +113,22 @@ class Stream::Base end end + # @return [void] + def participation_posts_for_stream!(posts) + return posts unless @user + + participations = Participation.where(:author_id => @user.person.id, :target_id => posts.map(&:id), :target_type => "Post") + + participation_hash = participations.inject({}) do |hash, participation| + hash[participation.target_id] = participation + hash + end + + posts.each do |post| + post.user_participation = participation_hash[post.id] + end + end + # @return [Hash] def publisher_opts {} |