A test project for HelpJuice
- Ruby =>
2.7.0
- Rails =>
6.0.3.5
PostgreSQL
database.Rspec
for testingPG_Search
for searching
After installing appropriate Ruby & Rails versions
- Run
bundle install
in the project directory - Run
rails db:create
, do update/add thedatabase.yml
with your credentials before running this... - Run
rails db:migrate
to run database migrations - Run
rails db:seed
to populate the database - Run
rails server
to run the rails server onlocalhost:3000
As search was not the focus of this project, to save time, I've used pg_search
.
As per my understanding, the goal of this assignment was to show trending searches (i.e. what people are searching)
So my algorithm is as follows
- I send a query to fetch the search results whenever there is a space after typed word (to save queries on each input)
- I show populate the dropdown with the search results so that user can select the appropriate article
- When user select the article I use that information to store the search as analytics (behind the scene I update the search count for that particular article)
- I've also added a
scope
to fetch trending searches - On view side, I've used simple
HTML
withBootstrap
to show search box, searched article list, and trending searches