From 47db48627b1cb4ccd37cdafe194a1aa18461ab99 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 28 Nov 2019 16:38:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=88=97=E8=A1=A8=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/admins/schools_controller.rb | 2 +- app/queries/admins/school_query.rb | 5 ----- app/views/admins/schools/shared/_list.html.erb | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/admins/schools_controller.rb b/app/controllers/admins/schools_controller.rb index 8c4f1d59e..7e1626d98 100644 --- a/app/controllers/admins/schools_controller.rb +++ b/app/controllers/admins/schools_controller.rb @@ -5,7 +5,7 @@ class Admins::SchoolsController < Admins::BaseController schools = Admins::SchoolQuery.call(params) - @schools = paginate schools + @schools = paginate schools.includes(:user_extensions) school_ids = @schools.map(&:id) @department_count = Department.where(school_id: school_ids).group(:school_id).count diff --git a/app/queries/admins/school_query.rb b/app/queries/admins/school_query.rb index c53b1222f..888cded97 100644 --- a/app/queries/admins/school_query.rb +++ b/app/queries/admins/school_query.rb @@ -17,11 +17,6 @@ class Admins::SchoolQuery < ApplicationQuery if keyword schools = schools.where('schools.name LIKE ?', "%#{keyword}%") end - Rails.logger.info("#########school_name: ##{schools.first.name}") - Rails.logger.info("#########school_id: ##{schools.first.id}") - schools = schools.joins("right join user_extensions on user_extensions.school_id = schools.id").group("schools.id") - Rails.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 diff --git a/app/views/admins/schools/shared/_list.html.erb b/app/views/admins/schools/shared/_list.html.erb index b1453f1a1..ec7475028 100644 --- a/app/views/admins/schools/shared/_list.html.erb +++ b/app/views/admins/schools/shared/_list.html.erb @@ -31,7 +31,7 @@ <%= school.province %> <%= school.city %> <%= school.address %> - <%= school.users_count %> + <%= school.user_extensions.count %> <%= @department_count.fetch(school.id, 0) %> <%= school.created_at&.strftime('%Y-%m-%d %H:%M') %>