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..47c7f117 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 @@ -56,7 +54,7 @@ class Management::SchoolDataContrastService end def select_columns - "school_id, school_name,"\ + "school_id, school_name, @total:=0, @other_total:=0,"\ "(@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,"\ diff --git a/app/views/managements/update_user.html.erb b/app/views/managements/update_user.html.erb index 3203614d..554ea2a2 100644 --- a/app/views/managements/update_user.html.erb +++ b/app/views/managements/update_user.html.erb @@ -188,7 +188,7 @@ name="business" value="<%= @user.business? ? "1" : "0" %>" id="person_business" class="magic-checkbox" style="float:left; margin-top: 8px;"> - +