Merge branch 'develop' into educoder

dev_ec
daiao 6 years ago
commit a259e7c63d

@ -2,7 +2,7 @@
class ChallengesController < ApplicationController class ChallengesController < ApplicationController
layout "base_shixun" layout "base_shixun"
# 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位 # 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位
#before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:index] before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:index]
before_filter :check_authentication, :except => [:index] before_filter :check_authentication, :except => [:index]
before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question, before_filter :find_shixun, :only => [:index, :new, :create, :destroy, :challenge_build, :update_evaluation, :add_choose_question, :new_choose_question,
:choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose] :choose_type_show, :edit_choose_question, :update_choose_question, :destroy_challenge_choose]

@ -2,7 +2,7 @@
class SubjectsController < ApplicationController class SubjectsController < ApplicationController
layout 'base_subject' layout 'base_subject'
# 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位 # 如要添加或修改before_filter时请将handle_openi_request这个before_filter放至第一位
#before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:show] before_filter :handle_openi_request, if: -> { user_login_and_from_openi? }, only: [:show]
before_filter :require_login, :except => [:show, :index] before_filter :require_login, :except => [:show, :index]
before_filter :check_authentication, :except => [:show, :index] before_filter :check_authentication, :except => [:show, :index]
before_filter :find_subject, :except => [:index, :new, :create, :create_subject, :new_subject, :append_to_stage, :send_to_course] before_filter :find_subject, :except => [:index, :new, :create, :create_subject, :new_subject, :append_to_stage, :send_to_course]

@ -42,7 +42,7 @@ class Management::SchoolReportService
shixun_homework_map = homeworks.where(homework_type: 4, courses: { school_id: ids }).group('school_id').count 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 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 course_map = courses.count
nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at') nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at')
active_course_map = courses.where(is_end: false).count active_course_map = courses.where(is_end: false).count
@ -76,11 +76,15 @@ class Management::SchoolReportService
when 'other_homework_count' then when 'other_homework_count' then
schools.joins(courses: :other_homework_commons).select("#{base_query_column}, COUNT(*) other_homework_count") schools.joins(courses: :other_homework_commons).select("#{base_query_column}, COUNT(*) other_homework_count")
when 'course_count' then 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 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 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 else
schools.joins(:teacher_extensions).select("#{base_query_column}, COUNT(*) teacher_count") schools.joins(:teacher_extensions).select("#{base_query_column}, COUNT(*) teacher_count")
end end

@ -4,9 +4,9 @@ wb.add_worksheet(name: '统计总表') do |sheet|
@schools.each do |school| @schools.each do |school|
sheet.add_row([ sheet.add_row([
school['id'].to_s, school['name'].to_s, (school['teacher_count'] || 0).to_s, (school['student_count'] || 0).to_s, school[:id].to_s, school[:name].to_s, (school[:teacher_count] || 0).to_s, (school[:student_count] || 0).to_s,
(school['course_count'] || 0).to_s, (school['active_course_count'] || 0).to_s, (school['homework_count'] || 0).to_s, (school[:course_count] || 0).to_s, (school[:active_course_count] || 0).to_s, (school[:homework_count] || 0).to_s,
(school['other_homework_count'] || 0).to_s, format_time(school['nearly_course_time']) (school[:other_homework_count] || 0).to_s, format_time(school[:nearly_course_time])
]) ])
end end
end end

@ -0,0 +1,5 @@
class AddIndexToCourses < ActiveRecord::Migration
def change
add_index :courses, [:school_id, :is_delete]
end
end
Loading…
Cancel
Save