精品课程默认排序

This commit is contained in:
huang 2016-01-24 08:48:38 +08:00
parent 21bdbe98a9
commit 49d0d214de
1 changed files with 7 additions and 2 deletions

View File

@ -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
# 判断精品课程是否可见,非课程成员无法查看私有课程