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

hjq_new_course
huang 10 years ago
parent ef57dc80d4
commit fee7cc4b2c

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

Loading…
Cancel
Save