From 16465edd8859c94dedf2da38f07d6afc46def712 Mon Sep 17 00:00:00 2001
From: Sam status:open
status:closed
status:archived
status:noreplies
status:singleuser
category:foo
user:foo
+ in:likes
in:posted
in:watching
in:tracking
in:private
in:bookmarks
diff --git a/lib/search.rb b/lib/search.rb index 31b0f270f..3b9500f96 100644 --- a/lib/search.rb +++ b/lib/search.rb @@ -192,6 +192,9 @@ class Search elsif word == 'in:private' @search_pms = true nil + elsif word == 'in:bookmarks' + @bookmarked_only = true + nil else word end @@ -329,11 +332,15 @@ class Search end if @guardian.user - if @liked_only + if @liked_only || @bookmarked_only + + post_action_type = PostActionType.types[:like] if @liked_only + post_action_type = PostActionType.types[:bookmark] if @bookmarked_only + posts = posts.where("posts.id IN ( SELECT pa.post_id FROM post_actions pa WHERE pa.user_id = #{@guardian.user.id} AND - pa.post_action_type_id = #{PostActionType.types[:like]} + pa.post_action_type_id = #{post_action_type} )") end @@ -341,6 +348,13 @@ class Search posts = posts.where("posts.user_id = #{@guardian.user.id}") end + if @search_bookmarks + post_action_type = @search_likes ? PostActionType.types(:like) : PostActionType.types[:bookmark] + posts = posts.where(["posts.id IN (SELECT post_id FROM post_actions + WHERE user_id = ? AND post_action_type_id = ?)", + @guardian.user.id, post_action_type]) + end + if @notification_level posts = posts.where("posts.topic_id IN ( SELECT tu.topic_id FROM topic_users tu