diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 533cead1..b1a66080 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1152,9 +1152,10 @@ class ApplicationController < ActionController::Base def user_login_and_from_openi url = request.referer.nil? ? Redmine::Configuration['educoder_domain'] : request.referer flag = URI(url).host == URI(Redmine::Configuration['openi_domain']).host && !current_user.logged? - logger.info "----------------------- #{url} -------------------------" - logger.info "----------------------- #{URI(url).host} --------------------------" - logger.info "----------------------- #{flag} -------------------------" + logger.info "----------------------- request referer: #{request.referer} -------------------------" + logger.info "----------------------- url after processed: #{url} -------------------------" + logger.info "----------------------- host: #{URI(url).host} --------------------------" + logger.info "----------------------- handle_flag: #{flag} -------------------------" flag end end diff --git a/app/controllers/managements/base_controller.rb b/app/controllers/managements/base_controller.rb index cbb61c33..8d5ada3b 100644 --- a/app/controllers/managements/base_controller.rb +++ b/app/controllers/managements/base_controller.rb @@ -1,5 +1,5 @@ class Managements::BaseController < ApplicationController layout 'base_management' - before_filter :require_admin + before_filter :require_business end \ No newline at end of file diff --git a/app/services/management/school_data_contrast_service.rb b/app/services/management/school_data_contrast_service.rb index 9390e46f..e6a39e9b 100644 --- a/app/services/management/school_data_contrast_service.rb +++ b/app/services/management/school_data_contrast_service.rb @@ -24,10 +24,8 @@ class Management::SchoolDataContrastService reports = reports.where("school_name LIKE :keyword OR school_id LIKE :keyword", keyword: "%#{keyword}%") end - reports = reports.group(:school_id) - count = reports.count.count - - reports = reports.limit(PAGE_SIZE).offset(offset) + count = reports.count('distinct(school_id)') + reports = reports.group(:school_id).limit(PAGE_SIZE).offset(offset) [count, reports] end @@ -57,9 +55,7 @@ class Management::SchoolDataContrastService def select_columns "school_id, school_name,"\ - "(@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" + "(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 end diff --git a/app/views/managements/schools/_data_contrast_list.html.erb b/app/views/managements/schools/_data_contrast_list.html.erb index ae2ecfd2..af63aee8 100644 --- a/app/views/managements/schools/_data_contrast_list.html.erb +++ b/app/views/managements/schools/_data_contrast_list.html.erb @@ -14,10 +14,9 @@