mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FEATURE: ninja op_likes sort for topic lists
This commit is contained in:
parent
0d1b460f1e
commit
cc23bb84d9
1 changed files with 5 additions and 0 deletions
|
@ -30,6 +30,7 @@ class TopicQuery
|
|||
# Maps `order` to a columns in `topics`
|
||||
SORTABLE_MAPPING = {
|
||||
'likes' => 'like_count',
|
||||
'op_likes' => 'op_likes',
|
||||
'views' => 'views',
|
||||
'posts' => 'posts_count',
|
||||
'activity' => 'bumped_at',
|
||||
|
@ -211,6 +212,10 @@ class TopicQuery
|
|||
return result.references(:categories).order(TopicQuerySQL.order_by_category_sql(sort_dir))
|
||||
end
|
||||
|
||||
if sort_column == 'op_likes'
|
||||
return result.order("(SELECT like_count FROM posts p3 WHERE p3.topic_id = topics.id AND p3.post_number = 1) #{sort_dir}")
|
||||
end
|
||||
|
||||
result.order("topics.#{sort_column} #{sort_dir}")
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue