diff --git a/app/services/resource_recommendation.rb b/app/services/resource_recommendation.rb index b9f8156e36..37189cbc0b 100644 --- a/app/services/resource_recommendation.rb +++ b/app/services/resource_recommendation.rb @@ -28,18 +28,14 @@ def resources matched_resources = [] moment_keywords = [] @moment.categories.each do |category| - moment_keywords.push(category['name'].split) - moment_keywords.push(html_clean(category['description']).split) + moment_keywords.push(category['name'].split, html_clean(category['description']).split) end @moment.moods.each do |mood| - moment_keywords.push(mood['name'].split) - moment_keywords.push(html_clean(mood['description']).split) + moment_keywords.push(mood['name'].split, html_clean(mood['description']).split) end @moment.strategies.each do |strategy| - moment_keywords.push(strategy['name'].split) - moment_keywords.push(html_clean(strategy['description']).split) + moment_keywords.push(strategy['name'].split, html_clean(strategy['description']).split) end - moment_keywords.push(moment_name, moment_why, moment_fix) moment_keywords = moment_keywords.flatten moment_keywords.each do |keyword| @@ -47,12 +43,10 @@ def resources end moment_keywords = moment_keywords.map(&:downcase) all_resources.each do |resource| - resource_tags = resource['tags'] - resource_tags.each do |tag| - tag.gsub!(%r{([_@#!%()\-=;><,{}\~\[\]\./\?\"\*\^\$\+\-]+)}, ' ') - tag.split + resource_tags = resource['tags'].map do |tag| + tag.split('_') end - unless (resource_tags & moment_keywords).empty? + unless (resource_tags.flatten & moment_keywords).empty? matched_resources.push(resource) end end