Merge pull request #179 from tms/users-like-like-posts

Users like like posts
This commit is contained in:
Sam 2013-02-17 13:57:52 -08:00
commit e8b3821b41
1 changed files with 6 additions and 2 deletions

View File

@ -42,12 +42,16 @@ class UserAction < ActiveRecord::Base
results = UserAction.select("action_type, COUNT(*) count, '' AS description")
.joins(:target_topic)
.where(user_id: user_id)
.group('action_type', 'topics.archetype')
.group('action_type')
# should push this into the sql at some point, but its simple enough for now
# We apply similar filters in stream, might consider trying to consolidate somehow
unless guardian.can_see_private_messages?(user_id)
results = results.where('topics.archetype <> ?', Archetype::private_message)
end
unless guardian.user && guardian.user.id == user_id
results = results.where("action_type <> ?", BOOKMARK)
end
results = results.to_a