统计调整

pre_develop
cxt 6 years ago
parent 8e2e10629a
commit f14bf75b30

@ -50,7 +50,8 @@ 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").where("courses.id != 1309 and ue.school_id = #{@school.id}") 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").
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对于量比较大的尽量不使用笛卡尔积

Loading…
Cancel
Save