advanced_filter I introduced
I needed a new option because default orders are evaluated after advanced_filter so I couldn’t use it.
Also, that part is a little bit more generic
elsif word =~ /order:\w+/ @order = word.gsub('order:', '').to_sym nil
After those changes, I can use them in plugins in this way:
Search.advanced_order(:votes) do |posts| posts.reorder("COALESCE((SELECT dvvc.counter FROM discourse_voting_vote_counters dvvc WHERE dvvc.topic_id = subquery.topic_id), 0) DESC") end