完成课程按tag搜索推荐
This commit is contained in:
parent
18c3c23d2c
commit
c5d935108e
|
@ -25,9 +25,8 @@ module CoursesHelper
|
|||
# 获取tag匹配结果ID
|
||||
a_tags = []
|
||||
# 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.find_all{|ect| kc.include? ect}.length != 0
|
||||
a_tags << ec.id
|
||||
end
|
||||
end
|
||||
|
@ -42,7 +41,7 @@ module CoursesHelper
|
|||
end
|
||||
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
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue