Search for pinned topics

Continuing the discussion from What advanced search filters should exist?:

Can’t seem to find an answer for this here yet…can you search for pinned topics?

1 Like

If I’m correct the available search filters come from /lib/search.rb

There are several “advanced_filter” lines but I see none for “pinned”

Unfortunately it might be a bit complex to code up.

The topics table has

pinned_at timestamp without time zone,
pinned_globally boolean DEFAULT false NOT NULL,
pinned_until timestamp without time zone,

and the topic_users table has

cleared_pinned_at timestamp without time zone,

I think something simple like

  advanced_filter(/status:pinned/) do |posts|
    posts.where('topics.pinned_at')
  end

might work, but accounting for when / if it is / will be un-pinned would take a bit more

4 Likes

The pinned search should exist @sam

5 Likes

Implemented per:

https://github.com/discourse/discourse/commit/77242e4680d310d0c152396824713ca2f8eb275a

4 Likes