From ebb575dd37fdf4b29b56d443ddd45528520a5881 Mon Sep 17 00:00:00 2001 From: stephanie-warmenhoven Date: Wed, 8 Apr 2020 01:16:19 -0700 Subject: [PATCH] [#1713] added gsub! to account for special characters but still need to fix code --- app/services/resource_recommendation.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/services/resource_recommendation.rb b/app/services/resource_recommendation.rb index 72b3a61fcb..bd23f760bf 100644 --- a/app/services/resource_recommendation.rb +++ b/app/services/resource_recommendation.rb @@ -36,8 +36,15 @@ def resources moment_keywords.push(moment_name, moment_why, moment_fix) moment_keywords = moment_keywords.flatten moment_keywords = moment_keywords.map(&:downcase) + moment_keywords.each do |keyword| + keyword.gsub!(/([_@#!%()\-=;><,{}\~\[\]\.\/\?\"\*\^\$\+\-]+)/, ' ') + end all_resources.each do |resource| - unless (resource['tags'] & moment_keywords).empty? + resource_tags = resource['tags'] + resource_tags.each do |tag| + tag.gsub!(/([_@#!%()\-=;><,{}\~\[\]\.\/\?\"\*\^\$\+\-]+)/, ' ') + end + unless (resource_tags & moment_keywords).empty? matched_resources.push(resource) end end