diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 2505a3bf..9f7b42e6 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -97,9 +97,12 @@ class CollegesController < ApplicationController shixun_ids = HomeworkCommonsShixuns.find_by_sql("SELECT hcs.shixun_id FROM homework_commons_shixuns hcs, homework_commons hc WHERE hc.course_id in (#{all_course_ids.map(&:id).join(',').strip == "" ? -1 : all_course_ids.map(&:id).join(',')}) AND hcs.homework_common_id = hc.id").map(&:shixun_id) - shixun_tags = TagRepertoire.find_by_sql("SELECT tr.`name`, COUNT(str.shixun_id) as shixun_count FROM tag_repertoires tr, shixun_tag_repertoires str WHERE tr.id = str.tag_repertoire_id AND str.shixun_id IN (#{shixun_ids.join(',').strip == "" ? -1 : shixun_ids.join(',')}) GROUP BY tr.id order by shixun_count desc") + shixun_tags = TagRepertoire.find_by_sql("SELECT tr.`name`, COUNT(str.shixun_id) as shixun_count FROM tag_repertoires tr, + shixun_tag_repertoires str WHERE tr.id = str.tag_repertoire_id AND str.shixun_id + IN (#{shixun_ids.join(',').strip == "" ? -1 : shixun_ids.join(',')}) GROUP BY tr.id + order by shixun_count desc") all_shixun_count = shixun_tags.map(&:shixun_count).sum - other_count = all_shixun_count - shixun_tags[0..8].map(&:shixun_count).sum + other_count = all_shixun_count.to_i - shixun_tags[0..8].map(&:shixun_count).sum.to_i @shixun_tags_name = [] @shixun_tags_data = [] shixun_tags[0..8].each do |tag| @@ -254,7 +257,7 @@ class CollegesController < ApplicationController def manager_auth # unless (User.current.admin? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present?) - unless (User.current.admin? || + unless (User.current.admin? || User.current.business? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present? || (User.current.user_extensions.try(:school_id) == @department.school_id && User.current.user_extensions.try(:identity) == 0) || (@department.school.try(:customer_id) && User.current.try(:partner).try(:customer_ids) && User.current.try(:partner).try(:customer_ids).include?(@department.school.try(:customer_id)))) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 729a9564..c9d41c0a 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -218,7 +218,7 @@ class WelcomeController < ApplicationController @tea_users = User.where(homepage_teacher: 1).includes(:user_extensions).limit(10).order("experience desc") @stu_users = User.includes(:user_extensions).where(user_extensions: {identity: 1}).limit(10).order("experience desc") - render :layout => 'base_local' + render :layout => 'educoder' end # 自动导入用户 diff --git a/app/services/management/school_data_contrast_service.rb b/app/services/management/school_data_contrast_service.rb index a1ad4c24..9390e46f 100644 --- a/app/services/management/school_data_contrast_service.rb +++ b/app/services/management/school_data_contrast_service.rb @@ -27,7 +27,9 @@ class Management::SchoolDataContrastService reports = reports.group(:school_id) count = reports.count.count - [count, SchoolDailyReport.find_by_sql(query_report_sql(reports.to_sql))] + reports = reports.limit(PAGE_SIZE).offset(offset) + + [count, reports] end private @@ -55,12 +57,9 @@ class Management::SchoolDataContrastService def select_columns "school_id, school_name,"\ - "SUM(IF(date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}', #{contrast_column}, 0)) total,"\ - "SUM(IF(date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}', #{contrast_column}, 0)) other_total" - end - - def query_report_sql(from_sql) - "SELECT reports.*, (other_total - total) increase, (IF(other_total - total = 0, 0.0, round((other_total - total) / IF(total = 0, 1, total), 5))) percentage "\ - "FROM (#{from_sql}) reports ORDER BY percentage #{sort_direction} LIMIT #{PAGE_SIZE} OFFSET #{offset}" + "(@total:=SUM(IF(date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}', #{contrast_column}, 0))) total,"\ + "(@other_total:=SUM(IF(date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}', #{contrast_column}, 0))) other_total,"\ + "(IF(@other_total - @total = 0, 0.0, round((@other_total - @total) / IF(@total = 0, 1, @total), 5))) percentage,"\ + "(@other_total - @total) increase" end end diff --git a/app/views/layouts/base_edu_user.html.erb b/app/views/layouts/base_edu_user.html.erb index 37ba85ca..8de851ea 100644 --- a/app/views/layouts/base_edu_user.html.erb +++ b/app/views/layouts/base_edu_user.html.erb @@ -7,23 +7,43 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'css/font-awesome','educoder/edu-main','educoder/edu-all','/assets/iconfont/iconfont.css', :media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/font-awesome','educoder/edu-main','educoder/edu-all','educoder/magic-check.css','/assets/iconfont/iconfont.css', :media => 'all' %> <%= javascript_heads %> + <%= javascript_include_tag 'edu/application', 'educoder/edu_application','educoder/edu_account',"educoder/edu_user" %> + <%= yield :header_tags -%> + + + +
-