@ -50,8 +50,7 @@ class CollegesController < ApplicationController
# Redo:这样做内存会卡死的
# Redo:这样做内存会卡死的
# user_ids = User.find_by_sql("SELECT users.id FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{@school.id}").map(&:id)
# user_ids = User.find_by_sql("SELECT users.id FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{@school.id}").map(&:id)
# Redo:是否直接使用count会更好
# Redo:是否直接使用count会更好
all_course_ids=Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").
all_course_ids=Course.where("id != 1309 and is_delete = 0 and school_id = #{@school.id}")
where("courses.id != 1309 and courses.is_delete = 0 and ue.school_id = #{@school.id}")
@courses_count=all_course_ids.size
@courses_count=all_course_ids.size
# Redo:对于量比较大的尽量不使用笛卡尔积
# Redo:对于量比较大的尽量不使用笛卡尔积
@ -132,7 +131,7 @@ class CollegesController < ApplicationController