|
|
|
@ -10,13 +10,19 @@ namespace :subjects do
|
|
|
|
|
Rails.logger.info("---------------------data_statistic: #{subject.id}")
|
|
|
|
|
sr = SubjectRecord.find_or_create_by!(subject_id: subject.id)
|
|
|
|
|
data = Subjects::DataStatisticService.new(subject)
|
|
|
|
|
study_count = data.study_count
|
|
|
|
|
# 总人数没有变化的话,不同课堂之类的变化了
|
|
|
|
|
course_study_count = (study_count == sr.study_count ? sr.course_study_count : data.course_study_count)
|
|
|
|
|
passed_count = (study_count == sr.study_count ? sr.passed_count : data.passed_count)
|
|
|
|
|
course_used_count = (study_count == sr.study_count ? sr.course_used_count : data.course_used_count)
|
|
|
|
|
school_used_count = (study_count == sr.study_count ? sr.school_used_count : data.school_used_count)
|
|
|
|
|
update_params = {
|
|
|
|
|
study_count: data.study_count,
|
|
|
|
|
course_study_count: data.course_study_count,
|
|
|
|
|
initiative_study: data.initiative_study,
|
|
|
|
|
passed_count: data.passed_count,
|
|
|
|
|
course_used_count: data.course_used_count,
|
|
|
|
|
school_used_count: data.school_used_count
|
|
|
|
|
study_count: study_count,
|
|
|
|
|
course_study_count: course_study_count,
|
|
|
|
|
initiative_study: (study_count - course_study_count),
|
|
|
|
|
passed_count: passed_count,
|
|
|
|
|
course_used_count: course_used_count,
|
|
|
|
|
school_used_count: school_used_count
|
|
|
|
|
}
|
|
|
|
|
sr.update_attributes!(update_params)
|
|
|
|
|
end
|
|
|
|
@ -31,7 +37,7 @@ namespace :subjects do
|
|
|
|
|
subjects.find_each do |subject|
|
|
|
|
|
puts("---------------------course_info_statistic: #{subject.id}")
|
|
|
|
|
Rails.logger.info("---------------------course_info_statistic: #{subject.id}")
|
|
|
|
|
data = Subjects::DataStatisticService.call(subject)
|
|
|
|
|
data = Subjects::CourseUsedInfoService.call(subject)
|
|
|
|
|
data.each do |key|
|
|
|
|
|
scr = SubjectCourseRecord.find_or_create_by!(school_id: key[:school_id], subject_id: subject.id)
|
|
|
|
|
update_params = {
|
|
|
|
@ -53,6 +59,8 @@ namespace :subjects do
|
|
|
|
|
Rails.logger.info("---------------------shixun_info_statistic_begin")
|
|
|
|
|
subjects = Subject.where(status: 2)
|
|
|
|
|
subjects.find_each(batch_size: 100) do |subject|
|
|
|
|
|
puts("---------------------shixun_info_statistic: #{subject.id}")
|
|
|
|
|
Rails.logger.info("---------------------shixun_info_statistic: #{subject.id}")
|
|
|
|
|
data = Subjects::ShixunUsedInfoService.call(subject)
|
|
|
|
|
data.each do |key|
|
|
|
|
|
ssi = SubjectShixunInfo.find_or_create_by!(shixun_id: key[:shixun_id], subject_id: subject.id)
|
|
|
|
|