Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommended resources issue 1713 #1720

Merged

Conversation

S-Warmenhoven
Copy link
Contributor

Description

Based on what a user has inputted in their Moment post (including tagged Categories, Moods, and Strategies), keywords are extracted and matched with Resource tags to display up to 3 recommended resources on the Moment Show Page. Additionally, there is a "More..." link to redirect the user to the Resources Index Page.
We created two classes called MomentKeywords and ResourceRecommendation that are called in the moments_controller for each Moment.

More Details

This is Phase #1 of this feature. There are some other ways to make the recommendations more optimal if necessary for further phases, such as using Text processing tools.

Further suggestions for the Recommendation engine:

  • Handle singular/plural
  • Handle related words (anxious/anxiety)
  • Resources need more tags or another type of tag
  • Filter by user location (country-specific resources)
  • Searching resources using the database can be more suitable for this feature than parsing and searching though the JSON file

Also, with the "More..." link, certain tags could be pre-selected too when directed to the index page.

Corresponding Issue

Issue [#1713]


Reviewing this pull request? Check out our Code Review Practices guide if you haven't already!

S-Warmenhoven and others added 28 commits April 15, 2020 20:54
@filter_tags = @matched_tags.map do |t|
"filter[]=#{t}&"
end
@filter_tags = @filter_tags.join()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line necessary? Nothing is being joined to @filter_tags.

tag.tr('_', '-')
end
end
matched_tags = (@moment_keywords & resource_tags)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be returning @moment_keywords & resource_tags instead of setting it to the matched_tags variable?

@S-Warmenhoven
Copy link
Contributor Author

Hello @nshki, @julianguyen, and other reviewers. We have updated our code according to the initial code reviews, and all local and external tests currently pass. Please let us know if you have any questions or concerns. Kind regards, TeamBits :)

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid work! Tests are great too!

Just a few more things and we should be ready to merge :)

@@ -43,6 +43,18 @@
</div>
<% end %>

<% if @resources.any? %>
<div class="smallMarginTop">
<div class="label"><%= label_tag "What resources could help?" %> </div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's unnecessary whitespace after the label_tag we should remove so that it looks like <div class="label"><%= label_tag "What resources could help?" %></div>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also realized that this text should be in our translation files. Feel free to use Google Translate for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Julia! Thank you for your comments. I do have 2 questions, please:

  1. With regards to the white space, I'm not sure which space you are referring to? To me the code and your example look exactly the same. Are you referring to the indent space?
<%= label_tag "What resources could help?" %>
<%= label_tag "What resources could help?" %>
2. Do we use the Chinese(Simplified) version for Google Translate?

<% @resources.take(3).each do |item| %>
<li><%= link_to item['name'], item['link'] %></li>
<%end %>
<li><%= link_to 'More...', "/resources?#{@resources_tags}" %></li>
Copy link
Member

@julianguyen julianguyen Apr 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"More..." should be in our translation files. Alternatively, you could use the existing t('load_more') key. If you decide to translate a new key, feel free to use Google Translate for now.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! :D This came together well 🎉

Thanks again for tackling this!

@julianguyen julianguyen merged commit edce780 into ifmeorg:master Apr 26, 2020
@AlineRibeiro
Copy link
Contributor

Thank you @julianguyen, @nshki and @S-Warmenhoven !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants