mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FEATURE: order:views order by views
This commit is contained in:
parent
e6cc4cba8b
commit
de71477405
2 changed files with 10 additions and 0 deletions
|
@ -2125,6 +2125,7 @@ en:
|
||||||
search_help: |
|
search_help: |
|
||||||
You may include special search operators:
|
You may include special search operators:
|
||||||
|
|
||||||
|
`order:views` Results will be ordered by view count (as opposed to relevence)
|
||||||
`order:latest` Results will be ordered by last post time (as opposed to relevence)
|
`order:latest` Results will be ordered by last post time (as opposed to relevence)
|
||||||
`status:open` Only show open topics
|
`status:open` Only show open topics
|
||||||
`status:closed` Only show closed topics
|
`status:closed` Only show closed topics
|
||||||
|
|
|
@ -159,6 +159,9 @@ class Search
|
||||||
elsif word == 'order:latest'
|
elsif word == 'order:latest'
|
||||||
@order = :latest
|
@order = :latest
|
||||||
nil
|
nil
|
||||||
|
elsif word == 'order:views'
|
||||||
|
@order = :views
|
||||||
|
nil
|
||||||
elsif word =~ /category:(.+)/
|
elsif word =~ /category:(.+)/
|
||||||
@category_id = Category.find_by('name ilike ?', $1).try(:id)
|
@category_id = Category.find_by('name ilike ?', $1).try(:id)
|
||||||
nil
|
nil
|
||||||
|
@ -346,6 +349,12 @@ class Search
|
||||||
else
|
else
|
||||||
posts = posts.order("posts.created_at DESC")
|
posts = posts.order("posts.created_at DESC")
|
||||||
end
|
end
|
||||||
|
elsif @order == :views
|
||||||
|
if opts[:aggregate_search]
|
||||||
|
posts = posts.order("MAX(topics.views) DESC")
|
||||||
|
else
|
||||||
|
posts = posts.order("topics.views DESC")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
posts = posts.order("TS_RANK_CD(TO_TSVECTOR(#{query_locale}, topics.title), #{ts_query}) DESC")
|
posts = posts.order("TS_RANK_CD(TO_TSVECTOR(#{query_locale}, topics.title), #{ts_query}) DESC")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue