search: add comment:<text>, note:<text> metatags.

This commit is contained in:
evazion
2020-04-27 23:54:54 -05:00
parent 4b38092b39
commit 7324f53752
2 changed files with 62 additions and 0 deletions

View File

@@ -34,6 +34,8 @@ class PostQueryBuilder
-ordfav ordfav
-favgroup favgroup ordfavgroup
-pool pool ordpool
-note note
-comment comment
-commentary commentary
-id id
-rating rating
@@ -195,6 +197,14 @@ class PostQueryBuilder
commentary_matches(value, quoted)
when "-commentary"
commentary_matches(value, quoted).negate
when "note"
note_matches(value)
when "-note"
note_matches(value).negate
when "comment"
comment_matches(value)
when "-comment"
comment_matches(value).negate
when "search"
saved_search_matches(value)
when "-search"
@@ -470,6 +480,14 @@ class PostQueryBuilder
favorites_include(username).joins(:favorites).merge(Favorite.for_user(user.id)).order("favorites.id DESC")
end
def note_matches(query)
Post.where(notes: Note.search(body_matches: query).reorder(nil))
end
def comment_matches(query)
Post.where(comments: Comment.search(body_matches: query).reorder(nil))
end
def commentary_matches(query, quoted = false)
case query.downcase
in "none" | "false" unless quoted