From 782258f222e3a735186ae52372c975a5131f6861 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 28 Nov 2019 15:29:03 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=AB=98=E6=A0=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/queries/admins/school_query.rb | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/app/queries/admins/school_query.rb b/app/queries/admins/school_query.rb
index 7361588c4..135cf87d0 100644
--- a/app/queries/admins/school_query.rb
+++ b/app/queries/admins/school_query.rb
@@ -13,11 +13,15 @@ class Admins::SchoolQuery < ApplicationQuery
     schools = School.all
 
     keyword = strip_param(:keyword)
-    schools = schools.where('schools.name LIKE ?', "%#{keyword}%") if keyword
-
-    schools = schools.joins(:user_extensions).group(:id)
+    logger.info("###########{keyword}")
+    if keyword
+      schools = schools.where('schools.name LIKE ?', "%#{keyword}%")
+    end
+    logger.info("#########school_name: ##{schools.first.name}")
+    logger.info("#########school_id: ##{schools.id}")
+    schools = schools.joins(:user_extensions).group("schools.id")
+    logger.info("#########school_id: ##{schools.first.id}")
     schools = schools.select('schools.*, COUNT(*) AS users_count')
-
     custom_sort schools, params[:sort_by], params[:sort_direction]
   end
 end
\ No newline at end of file