学校统计优化

dev_local_lzdx
xiaoxiaoqiong 3 years ago
parent afec8ccc57
commit 81db47dca8

@ -1,5 +1,6 @@
class StatisticSchoolDailyReportTask
def call
begin_evaluate = EvaluateRecord.where("created_at <'#{yesterday.first}'").reorder("id desc").limit(1)
School.find_each do |school|
# 新增教师和学生
users = User.joins(:user_extensions)
@ -30,6 +31,7 @@ class StatisticSchoolDailyReportTask
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN course_members ON course_members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON course_members.course_id = courses.id AND hc.course_id = courses.id')
.where("evaluate_records.id > ?", begin_evaluate.first.id)
.where(courses: { school_id: school.id })
.where(created_at: yesterday).reorder(nil).count
# shixun_evaluate_count = 0

Loading…
Cancel
Save