UX: remove `in:unpinned` filter from advanced search page. (#9911)

UX: remove in:unpinned filter from advanced search page. (#9911)

diff --git a/app/assets/javascripts/discourse/app/components/search-advanced-options.js b/app/assets/javascripts/discourse/app/components/search-advanced-options.js
index a2f6fcf..1be0744 100644
--- a/app/assets/javascripts/discourse/app/components/search-advanced-options.js
+++ b/app/assets/javascripts/discourse/app/components/search-advanced-options.js
@@ -21,7 +21,7 @@ const REGEXP_MIN_POST_COUNT_PREFIX = /^min_post_count:/gi;
 const REGEXP_POST_TIME_PREFIX = /^(before|after):/gi;
 const REGEXP_TAGS_REPLACE = /(^(tags?:|#(?=[a-z0-9\-]+::tag))|::tag\s?$)/gi;
 
-const REGEXP_IN_MATCH = /^(in|with):(posted|created|watching|tracking|bookmarks|first|pinned|unpinned|wiki|unseen|image)/gi;
+const REGEXP_IN_MATCH = /^(in|with):(posted|created|watching|tracking|bookmarks|first|pinned|wiki|unseen|image)/gi;
 const REGEXP_SPECIAL_IN_LIKES_MATCH = /^in:likes/gi;
 const REGEXP_SPECIAL_IN_TITLE_MATCH = /^in:title/gi;
 const REGEXP_SPECIAL_IN_PERSONAL_MATCH = /^in:personal/gi;
@@ -51,7 +51,6 @@ export default Component.extend({
     this.inOptionsForAll = [
       { name: I18n.t("search.advanced.filters.first"), value: "first" },
       { name: I18n.t("search.advanced.filters.pinned"), value: "pinned" },
-      { name: I18n.t("search.advanced.filters.unpinned"), value: "unpinned" },
       { name: I18n.t("search.advanced.filters.wiki"), value: "wiki" },
       { name: I18n.t("search.advanced.filters.images"), value: "images" }
     ];
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 1d2615f..3c85e21 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -2005,7 +2005,6 @@ en:
           bookmarks: I bookmarked
           first: are the very first post
           pinned: are pinned
-          unpinned: are not pinned
           seen: I read
           unseen: I've not read
           wiki: are wiki
diff --git a/lib/search.rb b/lib/search.rb
index 8d76057..fa0a0d7 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -354,14 +354,6 @@ class Search
     posts.where("topics.pinned_at IS NOT NULL")
   end
 
-  advanced_filter(/^in:unpinned$/) do |posts|
-    if @guardian.user
-      posts.where("topics.pinned_at IS NOT NULL AND topics.id IN (
-                  SELECT topic_id FROM topic_users WHERE user_id = ? AND cleared_pinned_at IS NOT NULL
-                 )", @guardian.user.id)
-    end
-  end
-
   advanced_filter(/^in:wiki$/) do |posts, match|
     posts.where(wiki: true)
   end
diff --git a/spec/components/search_spec.rb b/spec/components/search_spec.rb
index 599ea3c..1df963b 100644
--- a/spec/components/search_spec.rb
+++ b/spec/components/search_spec.rb
@@ -946,7 +946,7 @@ describe Search do
 
   describe 'Advanced search' do
 
-    it 'supports pinned and unpinned' do
+    it 'supports pinned' do
       topic = Fabricate(:topic)
       Fabricate(:post, raw: 'hi this is a test 123 123', topic: topic)
       _post = Fabricate(:post, raw: 'boom boom shake the room', topic: topic)
@@ -957,11 +957,6 @@ describe Search do
       guardian = Guardian.new(user)
 
       expect(Search.execute('boom in:pinned').posts.length).to eq(1)
-      expect(Search.execute('boom in:unpinned', guardian: guardian).posts.length).to eq(0)
-
-      topic.clear_pin_for(user)
-
-      expect(Search.execute('boom in:unpinned', guardian: guardian).posts.length).to eq(1)
     end
 
     it 'supports wiki' do
diff --git a/test/javascripts/acceptance/search-test.js b/test/javascripts/acceptance/search-test.js
index 018e3a0..f252bdc 100644
--- a/test/javascripts/acceptance/search-test.js
+++ b/test/javascripts/acceptance/search-test.js
@@ -135,7 +135,6 @@ QUnit.test("Right filters are shown to anonymous users", async assert => {
 
   assert.ok(inSelector.rowByValue("first").exists());
   assert.ok(inSelector.rowByValue("pinned").exists());
-  assert.ok(inSelector.rowByValue("unpinned").exists());
   assert.ok(inSelector.rowByValue("wiki").exists());
   assert.ok(inSelector.rowByValue("images").exists());
 
@@ -161,7 +160,6 @@ QUnit.test("Right filters are shown to logged-in users", async assert => {
 
   assert.ok(inSelector.rowByValue("first").exists());
   assert.ok(inSelector.rowByValue("pinned").exists());
-  assert.ok(inSelector.rowByValue("unpinned").exists());
   assert.ok(inSelector.rowByValue("wiki").exists());
   assert.ok(inSelector.rowByValue("images").exists());
 

GitHub sha: ce1491e8

1 Like

This commit appears in #9911 which was merged by vinothkannans.

This commit has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/search-for-topics-that-are-not-pinned-returns-unexpected-results/150855/8