From 9c3bff5e9f96170f1b714c199b0760c5bb9aef7f Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 19 Dec 2019 15:37:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E7=BB=9F=E8=AE=A1=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/colleges_controller.rb | 8 ++++---- app/views/colleges/student_shixun.json.jbuilder | 2 +- app/views/colleges/teachers.json.jbuilder | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/colleges_controller.rb b/app/controllers/colleges_controller.rb index 2be7f3cd4..707255866 100644 --- a/app/controllers/colleges_controller.rb +++ b/app/controllers/colleges_controller.rb @@ -44,8 +44,8 @@ class CollegesController < ApplicationController (SELECT count(c.id) FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.user_id=users.id AND m.role in (1,2,3) and c.school_id = #{current_school.id} AND c.is_delete = 0) as course_count FROM `users`, user_extensions ue where ue.school_id=#{current_school.id} and users.id=ue.user_id and ue.identity=0 ORDER BY publish_shixun_count desc, course_count desc, id desc LIMIT 10") # ).order("publish_shixun_count desc, experience desc").limit(10) - @teacher_count = UserExtension.where(school_id: current_school.id) - .select('SUM(IF(identity=0, 1, 0)) AS teachers_count').first.teachers_count + # @teacher_count = UserExtension.where(school_id: current_school.id) + # .select('SUM(IF(identity=0, 1, 0)) AS teachers_count').first.teachers_count @teachers = @teachers.map do |teacher| course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m WHERE c.id != 1309 and m.course_id = c.id AND m.role in (1,2,3) AND m.user_id=#{teacher.id} AND c.is_delete = 0 and c.school_id = #{current_school.id}") @@ -99,7 +99,7 @@ class CollegesController < ApplicationController @course_count = courses.size courses = courses.left_joins(practice_homeworks: { student_works: { myshixun: :games } }) - .select('courses.id, courses.name, courses.is_end, sum(games.evaluate_count) evaluating_count') + .select('courses.id, courses.name, courses.is_end, IFNULL(sum(games.evaluate_count), 0) evaluating_count') .group('courses.id').order('is_end asc, evaluating_count desc') @courses = paginate courses @@ -117,7 +117,7 @@ class CollegesController < ApplicationController # 学生实训 def student_shixun - @student_count = User.joins(:user_extension).where(user_extensions: { school_id: current_school.id, identity: 1 }).count + # @student_count = User.joins(:user_extension).where(user_extensions: { school_id: current_school.id, identity: 1 }).count @students = User.joins(:user_extension).where(user_extensions: { school_id: current_school.id, identity: 1 }).includes(:user_extension).order('experience desc').limit(10) student_ids = @students.map(&:id) diff --git a/app/views/colleges/student_shixun.json.jbuilder b/app/views/colleges/student_shixun.json.jbuilder index 431603afa..97e418148 100644 --- a/app/views/colleges/student_shixun.json.jbuilder +++ b/app/views/colleges/student_shixun.json.jbuilder @@ -7,4 +7,4 @@ json.teachers @students do |student| json.grade student.grade json.experience student.experience end -json.student_count @student_count \ No newline at end of file +# json.student_count @student_count \ No newline at end of file diff --git a/app/views/colleges/teachers.json.jbuilder b/app/views/colleges/teachers.json.jbuilder index 29b383fa4..1308f0cf4 100644 --- a/app/views/colleges/teachers.json.jbuilder +++ b/app/views/colleges/teachers.json.jbuilder @@ -8,4 +8,4 @@ json.teachers @teachers do |teacher| json.complete_rate teacher['complete_rate'] json.publish_shixun_count teacher['publish_shixun_count'] end -json.teacher_count @teacher_count \ No newline at end of file +# json.teacher_count @teacher_count \ No newline at end of file