Skip to content

Commit

Permalink
FEATURE: new search filter in:wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitjalan committed May 13, 2016
1 parent ae52f44 commit 5b03001
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/locales/server.en.yml
Expand Up @@ -2786,7 +2786,7 @@ en:
<tr><td><code>status:open</code></td><td><code>status:closed</code></td><td><code>status:archived</code></td><td><code>status:noreplies</code></td><td><code>status:single_user</code></td></tr>
<tr><td><code>#category-slug</code></td><td><code>category:foo</code></td><td><code>group:foo</code></td><td><code>badge:foo</code></td><td></td></tr>
<tr><td><code>in:likes</code></td><td><code>in:posted</code></td><td><code>in:watching</code></td><td><code>in:tracking</code></td><td><code>in:private</code></td></tr>
<tr><td><code>in:bookmarks</code></td><td><code>in:first</code></td><td><code>in:pinned</code></td><td><code>in:unpinned</code></td><td></td></tr>
<tr><td><code>in:bookmarks</code></td><td><code>in:first</code></td><td><code>in:pinned</code></td><td><code>in:unpinned</code></td><td><code>in:wiki</code></td></tr>
<tr><td><code>posts_count:num</code></td><td><code>before:days or date</code></td><td><code>after:days or date</code></td> <td colspan=2></td></tr>
</table>
</p>
Expand Down
4 changes: 4 additions & 0 deletions lib/search.rb
Expand Up @@ -231,6 +231,10 @@ def self.advanced_filters
end
end

advanced_filter(/in:wiki/) do |posts,match|
posts.where(wiki: true)
end

advanced_filter(/badge:(.*)/) do |posts,match|
badge_id = Badge.where('name ilike ? OR id = ?', match, match.to_i).pluck(:id).first
if badge_id
Expand Down
7 changes: 7 additions & 0 deletions spec/components/search_spec.rb
Expand Up @@ -426,6 +426,13 @@ def search
expect(Search.execute('boom in:unpinned', guardian: guardian).posts.length).to eq(1)
end

it 'supports wiki' do
topic = Fabricate(:topic)
wiki_post = Fabricate(:post, raw: 'this is a test 248', wiki: true, topic: topic)

expect(Search.execute('test 248 in:wiki').posts.length).to eq(1)
end

it 'supports before and after, in:first, user:, @username' do

time = Time.zone.parse('2001-05-20 2:55')
Expand Down

0 comments on commit 5b03001

Please sign in to comment.