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') %>