完成课程按tag搜索推荐

dev_hjq
huang 10 years ago
parent 18c3c23d2c
commit c5d935108e

@ -25,9 +25,8 @@ module CoursesHelper
# 获取tag匹配结果ID # 获取tag匹配结果ID
a_tags = [] a_tags = []
# kc = keywords.to_a # kc = keywords.to_a
Course.visible.where("is_excellent =?", 2).each do |ec| Course.visible.where("is_excellent =?", 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)}
#if ec.tags.find_all{|ect| kc.include? ect}.length != 0
a_tags << ec.id a_tags << ec.id
end end
end end
@ -42,7 +41,7 @@ module CoursesHelper
end end
a_courses << a_tags unless a_tags.length == 0 a_courses << a_tags unless a_tags.length == 0
# 过滤条件:精品课程、本身不在搜索范围 # 过滤条件:精品课程、本身不在搜索范围
e_courses = Course.where("is_excellent =? and id in (?)",1,a_courses.uniq).where("id !=?",current_course.id) e_courses = Course.where("is_excellent =? and id in (?)",1,a_courses.flatten.uniq).where("id !=?",current_course.id)
e_courses e_courses
end end

Loading…
Cancel
Save