From 2c99c6012b69c92d955a1a49b9e9202f4296ca37 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 11 Jan 2020 15:50:07 +0800 Subject: [PATCH] 1 --- app/controllers/subjects_controller.rb | 20 +++++++++++++++----- config/routes.rb | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index 8e23590ef..1ceece56f 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -5,7 +5,7 @@ class SubjectsController < ApplicationController before_action :find_subject, except: [:index, :create, :new, :append_to_stage, :add_shixun_to_stage] before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, :search_members, :add_subject_members, :statistics, :shixun_report, :school_report, - :up_member_position, :down_member_position, :update_team_title] + :up_member_position, :down_member_position, :update_team_title, :statistics_info] before_action :require_admin, only: [:copy_subject] before_action :shixun_marker, only: [:add_shixun_to_stage] @@ -456,7 +456,7 @@ class SubjectsController < ApplicationController end end - def statistics_new + def statistics_info # data = Subjects::DataStatisticService.new(@subject) # Rails.logger.info("study_count: #{data.study_count}") # Rails.logger.info("course_study_count: #{ data.course_study_count}") @@ -470,9 +470,19 @@ class SubjectsController < ApplicationController # data_2 = Subjects::ShixunUsedInfoService.call(@subject) # Rails.logger.info("study_count: #{data_2}") - data_3 = Subjects::UserUsedInfoService.call(@subject) - Rails.logger.info("study_count: #{data_3}") - render_ok() + # data_3 = Subjects::UserUsedInfoService.call(@subject) + # Rails.logger.info("study_count: #{data_3}") + + @data = + if params[:type] == "shixun_info" + @subject.subject_shixun_infos + elsif params[:type] == "user_info" + @subject.subject_user_infos + else + @subject.subject_course_records + end + @data = paginate custom_sort(@data, params[:sort_by], params[:sort_direction]) + end def shixun_report diff --git a/config/routes.rb b/config/routes.rb index 5a7b641f6..3a17da281 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -394,7 +394,7 @@ Rails.application.routes.draw do get 'cancel_publish' get 'cancel_has_publish' get 'statistics' - get 'statistics_new' + get 'statistics_info' get 'shixun_report' get 'school_report' post 'update_attr'