Skip to content

Commit

Permalink
[ifmeorg#1713] Modified matched_tags to supply filter_tags
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Warmenhoven authored and AlineRibeiro committed Apr 23, 2020
1 parent 5f04809 commit 6d83513
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
10 changes: 5 additions & 5 deletions app/controllers/moments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ def index
def show
show_with_comments(@moment)
@resources = ResourceRecommendations.new(@moment).call
# @matched_tags = ResourceRecommendations.new(@moment).matched_tags
@matched_tags = ResourceRecommendations.new(@moment).matched_tags
@moment_keywords = MomentKeywords.new(@moment).call
# @filter_tags = @matched_tags.map do |t|
# "filter[]=#{t}&"
# end
# @filter_tags = @filter_tags.join()
@filter_tags = @matched_tags.map do |t|
"filter[]=#{t}&"
end
@filter_tags = @filter_tags.join()
end

# GET /moments/new
Expand Down
18 changes: 9 additions & 9 deletions app/services/resource_recommendations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def call
end
end

# def matched_tags
# @moment_keywords = MomentKeywords.new(@moment).call
# resource_tags = all_resources.flat_map do |resource|
# resource['tags'].map do |tag|
# tag.tr('_', '-')
# end
# end
# matched_tags = (@moment_keywords & resource_tags)
# end
def matched_tags
@moment_keywords = MomentKeywords.new(@moment).call
resource_tags = all_resources.flat_map do |resource|
resource['tags'].select do |tag|
@moment_keywords.match?(tag)
end
end
resource_tags
end

private

Expand Down
1 change: 1 addition & 0 deletions app/views/moments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<li><%= link_to 'More...', "/resources?#{@filter_tags}" %></li>
</ul>
</div>
<%= @filter_tags %>
<%= "Moment keywords:" "#{@moment_keywords}" %>
<% end %>

Expand Down

0 comments on commit 6d83513

Please sign in to comment.