课程推荐中不显示私有课程

This commit is contained in:
huang 2016-03-03 18:10:30 +08:00
parent ef57dc80d4
commit fee7cc4b2c
1 changed files with 2 additions and 2 deletions

View File

@ -25,7 +25,7 @@ module CoursesHelper
# 获取tag匹配结果ID
a_tags = []
# kc = keywords.to_a
Course.visible.where("is_excellent =?", 1).each do |ec|
Course.visible.where("is_excellent =? and is_public =?", 1, 1).each do |ec|
if ec.tags.any?{|value| current_course.name.include?(value.to_s)}
a_tags << ec.id
end
@ -44,7 +44,7 @@ module CoursesHelper
excellent_ids = a_courses.flatten.uniq.delete_if{|i| i == current_course.id}
limit = 5 - excellent_ids.length.to_i
sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id
and c.is_excellent =1 and c.id != #{current_course.id} order by cs.updated_at desc;"
and c.is_excellent =1 and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;"
default_ecourse_ids = Course.find_by_sql(sql).flatten
# REDO:时间紧,待优化
default_ids =[]