From 4f5ff41d0935609d1c552f0405e55881b002cb88 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 14 Jan 2020 18:41:41 +0800 Subject: [PATCH] 1 --- app/services/shixun_search_service.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/services/shixun_search_service.rb b/app/services/shixun_search_service.rb index 22d2d67c8..c8db74325 100644 --- a/app/services/shixun_search_service.rb +++ b/app/services/shixun_search_service.rb @@ -50,11 +50,12 @@ class ShixunSearchService < ApplicationService private def search_options + model_options = { includes: [ :shixun_info, :challenges, :subjects, user: { user_extension: :school } ] } model_options.merge!(where: { id: @shixuns.pluck(:id) }) - model_options.merge!(order: sort_str) + model_options.merge!(order: {sort_str => order_str}) model_options.merge!(default_options) model_options end @@ -64,10 +65,6 @@ class ShixunSearchService < ApplicationService end def sort_str - if params[:sort] == "myshixuns_count" - "is_wechat_support=1 desc, myshixuns_count #{order_str}" - else - "myshixuns_count #{order_str}" - end + params[:sort] || "myshixuns_count" end end \ No newline at end of file