|
|
|
@ -42,7 +42,7 @@ class Management::SchoolReportService
|
|
|
|
|
shixun_homework_map = homeworks.where(homework_type: 4, courses: { school_id: ids }).group('school_id').count
|
|
|
|
|
other_homework_map = homeworks.where(homework_type: [1, 3], courses: { school_id: ids }).group('school_id').count
|
|
|
|
|
|
|
|
|
|
courses = Course.where(school_id: ids).group('school_id')
|
|
|
|
|
courses = Course.where(is_delete: 0, school_id: ids).group('school_id')
|
|
|
|
|
course_map = courses.count
|
|
|
|
|
nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at')
|
|
|
|
|
active_course_map = courses.where(is_end: false).count
|
|
|
|
@ -76,11 +76,15 @@ class Management::SchoolReportService
|
|
|
|
|
when 'other_homework_count' then
|
|
|
|
|
schools.joins(courses: :other_homework_commons).select("#{base_query_column}, COUNT(*) other_homework_count")
|
|
|
|
|
when 'course_count' then
|
|
|
|
|
schools.joins(:courses).select("#{base_query_column}, COUNT(*) course_count")
|
|
|
|
|
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
|
|
|
|
|
.select("#{base_query_column}, COUNT(*) course_count")
|
|
|
|
|
when 'nearly_course_time' then
|
|
|
|
|
schools.joins(courses: :course_activities).select("#{base_query_column}, MAX(course_activities.updated_at) nearly_course_time")
|
|
|
|
|
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
|
|
|
|
|
.joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id')
|
|
|
|
|
.select("#{base_query_column}, MAX(acs.updated_at) nearly_course_time")
|
|
|
|
|
when 'active_course_count' then
|
|
|
|
|
schools.joins(:active_courses).select("#{base_query_column}, COUNT(*) active_course_count")
|
|
|
|
|
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0 AND cs.is_end = false')
|
|
|
|
|
.select("#{base_query_column}, COUNT(*) active_course_count")
|
|
|
|
|
else
|
|
|
|
|
schools.joins(:teacher_extensions).select("#{base_query_column}, COUNT(*) teacher_count")
|
|
|
|
|
end
|
|
|
|
|