学校统计不正确的问题

dev_ec
daiao 5 years ago
parent adbfde1425
commit c6d880e5d2

@ -368,7 +368,7 @@ class SubjectsController < ApplicationController
@schools.map do |s|
school_courses = Course.where(id: course_ids, school_id: s.id)
course_count = school_courses.count
student_count = StudentsForCourse.where(course_id: school_courses.pluck(:id)).count
student_count = CourseMember.where(course_id: school_courses.pluck(:id), role: 4).count
homework_count = HomeworkCommon.find_by_sql("select count(*) cnt from homework_commons hc join courses c on hc.course_id = c.id
where c.school_id = #{s.id} and hc.id in(#{homework_common_id})").first.try(:cnt)
s.attributes.dup.merge({name: s.name, course_count: course_count, student_count: student_count,homework_count: homework_count})

Loading…
Cancel
Save