2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FEATURE: new search filter - @username

This commit is contained in:
Arpit Jalan 2016-05-12 14:13:44 +05:30
parent 628773258e
commit 00893ef1de
3 changed files with 15 additions and 4 deletions

View file

@ -279,7 +279,7 @@ class Search
end
end
advanced_filter(/^\#([a-zA-Z0-9,\-:]+)/) do |posts,match|
advanced_filter(/^\#([a-zA-Z0-9\-:]+)/) do |posts,match|
slug = match.to_s.split(":")
if slug[1]
# sub category
@ -315,6 +315,15 @@ class Search
end
end
advanced_filter(/^\@([a-zA-Z0-9_\-.]+)/) do |posts,match|
user_id = User.where(staged: false).where(username_lower: match.downcase).pluck(:id).first
if user_id
posts.where("posts.user_id = #{user_id}")
else
posts.where("1 = 0")
end
end
advanced_filter(/before:(.*)/) do |posts,match|
if date = Search.word_to_date(match)
posts.where("posts.created_at < ?", date)