|
|
|
@ -16,15 +16,20 @@ namespace :subjects do
|
|
|
|
|
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: 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)
|
|
|
|
|
unless course_study_count == sr.course_study_count &&
|
|
|
|
|
passed_count == sr.passed_count &&
|
|
|
|
|
course_used_count == sr.course_used_count &&
|
|
|
|
|
school_used_count == sr.school_used_count
|
|
|
|
|
update_params = {
|
|
|
|
|
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
|
|
|
|
|
end
|
|
|
|
|
puts("---------------------data_statistic_end")
|
|
|
|
|
Rails.logger.info("---------------------data_statistic_end")
|
|
|
|
@ -40,14 +45,20 @@ namespace :subjects do
|
|
|
|
|
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 = {
|
|
|
|
|
school_name: key[:school_name],
|
|
|
|
|
course_count: key[:course_count],
|
|
|
|
|
student_count: key[:student_count],
|
|
|
|
|
choice_shixun_num: key[:choice_shixun_num],
|
|
|
|
|
choice_shixun_frequency: key[:choice_shixun_frequency]
|
|
|
|
|
}
|
|
|
|
|
scr.update_attributes(update_params)
|
|
|
|
|
unless key[:school_name] == scr.school_name &&
|
|
|
|
|
key[:course_count] == scr.course_count &&
|
|
|
|
|
key[:student_count] == scr.student_count &&
|
|
|
|
|
key[:choice_shixun_num] == scr.choice_shixun_num &&
|
|
|
|
|
key[:choice_shixun_frequency] == scr.choice_shixun_frequency
|
|
|
|
|
update_params = {
|
|
|
|
|
school_name: key[:school_name],
|
|
|
|
|
course_count: key[:course_count],
|
|
|
|
|
student_count: key[:student_count],
|
|
|
|
|
choice_shixun_num: key[:choice_shixun_num],
|
|
|
|
|
choice_shixun_frequency: key[:choice_shixun_frequency]
|
|
|
|
|
}
|
|
|
|
|
scr.update_attributes(update_params)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
puts("---------------------course_info_statistic_end")
|
|
|
|
@ -64,18 +75,26 @@ namespace :subjects do
|
|
|
|
|
data = Subjects::ShixunUsedInfoService.call(subject)
|
|
|
|
|
data.each do |key|
|
|
|
|
|
ssi = SubjectShixunInfo.find_or_create_by!(shixun_id: key[:shixun_id], subject_id: subject.id)
|
|
|
|
|
update_params = {
|
|
|
|
|
stage: key[:stage],
|
|
|
|
|
shixun_name: key[:name],
|
|
|
|
|
challenge_count: key[:challenge_count],
|
|
|
|
|
course_count: key[:course_count],
|
|
|
|
|
school_count: key[:school_count],
|
|
|
|
|
used_count: key[:used_count],
|
|
|
|
|
passed_count: key[:passed_count],
|
|
|
|
|
evaluate_count: key[:evaluate_count],
|
|
|
|
|
passed_ave_time: key[:passed_ave_time]
|
|
|
|
|
}
|
|
|
|
|
ssi.update_attributes(update_params)
|
|
|
|
|
unless key[:challenge_count] == ssi.challenge_count &&
|
|
|
|
|
key[:course_count] == ssi.course_count &&
|
|
|
|
|
key[:school_count] == ssi.school_count &&
|
|
|
|
|
key[:used_count] == ssi.used_count &&
|
|
|
|
|
key[:passed_count] == ssi.passed_count &&
|
|
|
|
|
key[:evaluate_count] == ssi.evaluate_count &&
|
|
|
|
|
key[:passed_ave_time] == ssi.passed_ave_time
|
|
|
|
|
update_params = {
|
|
|
|
|
stage: key[:stage],
|
|
|
|
|
shixun_name: key[:name],
|
|
|
|
|
challenge_count: key[:challenge_count],
|
|
|
|
|
course_count: key[:course_count],
|
|
|
|
|
school_count: key[:school_count],
|
|
|
|
|
used_count: key[:used_count],
|
|
|
|
|
passed_count: key[:passed_count],
|
|
|
|
|
evaluate_count: key[:evaluate_count],
|
|
|
|
|
passed_ave_time: key[:passed_ave_time]
|
|
|
|
|
}
|
|
|
|
|
ssi.update_attributes(update_params)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
puts("---------------------shixun_info_statistic_end")
|
|
|
|
@ -83,7 +102,7 @@ namespace :subjects do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
task user_info_statistic: :environment do
|
|
|
|
|
puts("---------------------user_info_statistic_begin")
|
|
|
|
|
puts("---------------------vim ./")
|
|
|
|
|
Rails.logger.info("---------------------user_info_statistic_begin")
|
|
|
|
|
subjects = Subject.where(status: 2)
|
|
|
|
|
subjects.find_each(batch_size: 100) do |subject|
|
|
|
|
@ -91,15 +110,22 @@ namespace :subjects do
|
|
|
|
|
data = Subjects::UserUsedInfoService.call(subject)
|
|
|
|
|
data.each do |key|
|
|
|
|
|
sui = SubjectUserInfo.find_or_create_by!(user_id: key[:user_id], subject_id: subject.id)
|
|
|
|
|
update_params = {
|
|
|
|
|
username: key[:name],
|
|
|
|
|
passed_myshixun_count: key[:passed_myshixun_count],
|
|
|
|
|
passed_games_count: key[:passed_games_count],
|
|
|
|
|
code_line_count: key[:code_line_count],
|
|
|
|
|
evaluate_count: key[:evaluate_count],
|
|
|
|
|
cost_time: key[:cost_time]
|
|
|
|
|
}
|
|
|
|
|
sui.update_attributes(update_params)
|
|
|
|
|
unless key[:passed_myshixun_count] == sui.passed_myshixun_count &&
|
|
|
|
|
key[:passed_games_count] == sui.passed_games_count &&
|
|
|
|
|
key[:code_line_count] == sui.code_line_count &&
|
|
|
|
|
key[:evaluate_count] == sui.evaluate_count &&
|
|
|
|
|
key[:cost_time] == sui.cost_time
|
|
|
|
|
update_params = {
|
|
|
|
|
username: key[:name],
|
|
|
|
|
passed_myshixun_count: key[:passed_myshixun_count],
|
|
|
|
|
passed_games_count: key[:passed_games_count],
|
|
|
|
|
code_line_count: key[:code_line_count],
|
|
|
|
|
evaluate_count: key[:evaluate_count],
|
|
|
|
|
cost_time: key[:cost_time]
|
|
|
|
|
}
|
|
|
|
|
sui.update_attributes(update_params)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
puts("---------------------user_info_statistic_end")
|
|
|
|
|