From f8f3aefd0d4163fe14b6f8ce893bd286318e5517 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 21 Jun 2019 15:09:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E9=A3=8E?= =?UTF-8?q?=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 7 +++++-- app/views/shixuns/_top.json.jbuilder | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ef52632e7..3d0926994 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -52,7 +52,9 @@ class CoursesController < ApplicationController # u.login), s.name from courses c, users u, user_extensions ue, schools s where c.is_delete=0 and # c.tea_id=u.id and u.id=ue.user_id and ue.school_id=s.id") - @courses = Course.where(is_delete: 0, is_hidden: 0).includes(:course_modules, :course_members, teacher: [user_extension: :school]).order("courses.id = 1309 desc, courses.created_at desc") + @courses = Course.where(is_delete: 0, is_hidden: 0) + .includes(:course_modules, :course_members, teacher: [user_extension: :school]) + .order("courses.id = 1309 desc, courses.created_at desc") # @courses = Course.where(is_delete: 0, is_hidden: 0).select("courses.id, courses.tea_id, courses.name, courses.exercises_count, courses.polls_count, # courses.is_public, courses.is_end, courses.visits, courses.course_members_count,courses.homework_commons_count,(SELECT MAX(created_at) @@ -87,7 +89,8 @@ class CoursesController < ApplicationController (course_members.role in(1,2,3) and CONCAT(users.lastname, users.firstname) like :keyword) or courses.name like :keyword or schools.name like :keyword } - @courses = @courses.joins(course_members: [user: [user_extension: :school]]).where("#{sql}", keyword: "%#{params[:search]}%").distinct + @courses = @courses.joins(course_members: [user: [user_extension: :school]]) + .where("#{sql}", keyword: "%#{params[:search]}%").distinct end @courses_count = @courses.size diff --git a/app/views/shixuns/_top.json.jbuilder b/app/views/shixuns/_top.json.jbuilder index f741e9021..ef15e2515 100644 --- a/app/views/shixuns/_top.json.jbuilder +++ b/app/views/shixuns/_top.json.jbuilder @@ -15,5 +15,4 @@ json.experience shixun.all_score json.diffcult diff_to_s(shixun.trainee) json.score_info shixun.shixun_preference_info # todo: 这块可以改成只显示实训的平均分,不用每次都去取每种星的分数了。 # 用于是否显示导航栏中的'背景知识' -json.propaedeutics shixun.propaedeutics.present? ? true : false - +json.propaedeutics shixun.propaedeutics.present?