From 49d0d214def26c6ec79ba64b932e124314a008b3 Mon Sep 17 00:00:00 2001 From: huang Date: Sun, 24 Jan 2016 08:48:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E5=93=81=E8=AF=BE=E7=A8=8B=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index fb7214fce..2d2d83174 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -40,9 +40,14 @@ module CoursesHelper a_courses << c.id end a_courses << a_tags unless a_tags.length == 0 + ids = a_courses.flatten.uniq + ids_count = ids.length + limit = 5 - ids_count.to_i + sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id and c.is_excellent =1 order by cs.updated_at desc;" + default_ecourse = Course.find_by_sql(sql).where("id is not in (?)", a_courses.ids) + arr_result = ids << default_ecourse # 过滤条件:精品课程、本身不在搜索范围 - e_courses = Course.where("is_excellent =? and id in (?)",1,a_courses.flatten.uniq).where("id !=?",current_course.id) - e_courses + e_courses = Course.where("is_excellent =? and id in (?)",1,).where("id !=?", arr_result, current_course.id) end # 判断精品课程是否可见,非课程成员无法查看私有课程