Skip to content

Commit

Permalink
[ifmeorg#1713] modified resource tags to account for underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Warmenhoven committed Apr 9, 2020
1 parent 8f86346 commit 9d67ddc
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions app/services/resource_recommendation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,25 @@ 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|
keyword.gsub!(%r{([_@#!%()\-=;><,{}\~\[\]\./\?\"\*\^\$\+\-]+)}, '')
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
Expand Down

0 comments on commit 9d67ddc

Please sign in to comment.